-
Notifications
You must be signed in to change notification settings - Fork 164
Bridge api for frontend
This API used for anyswap bridge frontend.
API URL: https://bridgeapi.anyswap.exchange/v2/
Bridge interface:
Anyswap https://anyswap.exchange/bridge
Multichain https://multichain.xyz/
Spookyswap https://spookyswap.finance/bridge
No. | Mainnet | chainID |
---|---|---|
1 | Ethereum | 1 |
2 | BSC | 56 |
3 | xDai | 100 |
4 | HECO | 128 |
5 | Matic | 137 |
6 | Fantom | 250 |
7 | Fusion | 32659 |
8 | Avax | 43114 |
9 | Bitocin | BTC |
10 | Litecoin | LTC |
11 | Blocknet | BLOCK |
https://bridgeapi.anyswap.exchange/v2/serverInfo/chainid
Example: get the ethereum bridge info.
https://bridgeapi.anyswap.exchange/v2/serverInfo/1
{
"btc":{
"PairID":"BTC",
"SrcToken":{
"ID":"BTC",
"Name":"Bitcoin Coin",
"Symbol":"BTC",
"Decimals":8,
"Description":"Bitcoin Coin",
"DepositAddress":"1918DgsaJCsRF5E5rTp2AsE5XyFTF95tTQ",
"DcrmAddress":"1918DgsaJCsRF5E5rTp2AsE5XyFTF95tTQ",
"MaximumSwap":100,
"MinimumSwap":0.01,
"BigValueThreshold":20,
"SwapFeeRate":0,
"MaximumSwapFee":0,
"MinimumSwapFee":0,
"PlusGasPricePercentage":10,
"DisableSwap":false
},
"DestToken":{
"ID":"BTC",
"Name":"Bitcoin Coin",
"Symbol":"anyBTC",
"Decimals":8,
"Description":"cross chain bridge BTC to anyBTC",
"DcrmAddress":"0x49ADdC76569402cf893C015ac69A177Aaf4e822B",
"ContractAddress":"0x51600b0cff6bbf79e7767158c41fd15e968ec404",
"MaximumSwap":100,
"MinimumSwap":0.01,
"BigValueThreshold":10,
"SwapFeeRate":0.001,
"MaximumSwapFee":0.01,
"MinimumSwapFee":0.002,
"PlusGasPricePercentage":1,
"DisableSwap":false
}
}
}
Get more bridge config info here.
This API used for new account, just need to call one time before first deposit on one bridge.
https://bridgeapi.anyswap.exchange/v2/register/receiveAccount/chainID/pairID
Example: get the bitcoin deposit address.
https://bridgeapi.anyswap.exchange/v2/register/0xC03033d8b833fF7ca08BF2A58C9BC9d711257249/1/BTC
{
"msg":"Success",
"info":{
"BindAddress":"0xC03033d8b833fF7ca08BF2A58C9BC9d711257249",
"P2shAddress":"3JtGZKogfzRC48yBQCrCxgyD4iEMSasXan",
"RedeemScript":"14c03033d8b833ff7ca08bf2a58c9bc9d7112572497576a91457c7083cd9bd69c96f70a0e30f7c61d70ae0166e88ac",
"RedeemScriptDisasm":"c03033d8b833ff7ca08bf2a58c9bc9d711257249 OP_DROP OP_DUP OP_HASH160 57c7083cd9bd69c96f70a0e30f7c61d70ae0166e OP_EQUALVERIFY OP_CHECKSIG"
}
}
The P2SH btc address is receive account's deposit address. After deposit BTC to the p2sh address(more then 1 confirm), receive account will get anyBTC token on ethereum.
This transaction status update every 60s.
Old API: https://bridgeapi.anyswap.exchange/v2/getHashStatus/receiveAccount/txHash/chainID/pairID/srcChainID
Example: get the bitcoin deposit transaction status.
{
"msg":"Success",
"info":{
"pairid":"btc",
"txid":"844e69f3fd34d294e0c7511d633f63eb533b9c9c5d6340cfd05c82d52d26c55d",
"txto":"",
"txheight":668778,
"txtime":1612287325,
"from":"1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s",
"to":"3FXnhVBVUhTeqYyh8LMianFrzHWU4WBwN6",
"bind":"0x4e96b1d50f77c99f0e1dF50D75Aeec6edb124250",
"value":"8464276",
"swaptx":"0x99d6c15e599e2c49f49d629676fe1b43ed0f7ca68186ae4026880bd1d6c8ff1e",
"swapheight":11778287,
"swaptime":1612288529,
"swapvalue":"8464276",
"swaptype":1,
"swapnonce":46,
"status":10,
"statusmsg":"MatchTxStable",
"timestamp":1612288856,
"memo":"",
"confirmations":107031
}
}
amount: withdraw btc amount.
bindaddr: withdraw btc address.
function Swapout(uint256 amount, string memory bindaddr)
anyBTC contract address on ethereum: 0x51600B0CfF6Bbf79E7767158C41FD15e968Ec404
anyBTC contract code: here
After the anyBTC swapout transaction confirmed, withdraw BTC address will receive BTC on bitcoin network.
This transaction status update every 60s.
Example: get the bitcoin withdraw transaction status.
{
"msg":"Success",
"info":{
"pairid":"btc",
"txid":"0xe20921404818db879c179c1c968936e1aee34040abdc0cd215c4721d41f54fb2",
"txto":"0x51600b0cff6bbf79e7767158c41fd15e968ec404",
"txheight":11778311,
"txtime":1612288744,
"from":"0x4e96b1d50f77c99f0e1df50d75aeec6edb124250",
"to":"0x51600b0cff6bbf79e7767158c41fd15e968ec404",
"bind":"1NWt7rjtjRXN7iGA51qnfEe1uosdPEcQnQ",
"value":"8464276",
"swaptx":"7586ad501ae1e20ba5ee0d2b26bcfe65ba0aa98cf8228481566d7c8a7c0179e4",
"swapheight":668782,
"swaptime":1612290997,
"swapvalue":"8264276",
"swaptype":2,
"swapnonce":0,
"status":10,
"statusmsg":"MatchTxStable",
"timestamp":1612292043,
"memo":"",
"confirmations":2430
}
}
Get the deposit and withdraw history by account.
Example: get usdc to fantom deposit history by account.
{
"msg":"Success",
"info":[
{
"pairid":"usdcv2",
"txid":"0xfbafd17a5a59ff880e76ddb480ce3bce70e6ecc732e1670b9695cfc34ab82281",
"txto":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"txheight":11895407,
"txtime":1613845524,
"from":"0x2d407ddb06311396fe14d4b49da5f0471447d45c",
"to":"0xc564ee9f21ed8a2d8e7e76c085740d5e4c5fafbe",
"bind":"0x2d407ddb06311396fe14d4b49da5f0471447d45c",
"value":"20000000000",
"swaptx":"0x10c13479d2bb544725f7fc3eb1b3bb3de9668909c68cbbec749622a0a4e5e6d4",
"swapheight":2337021,
"swaptime":1613914551,
"swapvalue":"19980000000",
"swaptype":1,
"swapnonce":13,
"status":10,
"statusmsg":"MatchTxStable",
"timestamp":1613914741,
"memo":"",
"confirmations":49391
}
]
}
Example: get all tokens from ethereum to fantom withdraw history by account.
{
"msg":"Success",
"info":[
{
"pairid":"daiv2",
"txid":"0x21b0ff5c8777340461ce2800aa1783c98e9e88e274c6f556c770ac607b15b752",
"txto":"0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e",
"txheight":2321623,
"txtime":1613848873,
"from":"0x2d407ddb06311396fe14d4b49da5f0471447d45c",
"to":"0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e",
"bind":"0x2D407dDb06311396fE14D4b49da5F0471447d45C",
"value":"100000000000000000000",
"swaptx":"0x1ddd0a4d083a58954db54b44f1cb2d0d0d5ba9689a31aa410ba1374997c95ff4",
"swapheight":11895693,
"swaptime":1613849057,
"swapvalue":"85000000000000000000",
"swaptype":2,
"swapnonce":5,
"status":10,
"statusmsg":"MatchTxStable",
"timestamp":1613849259,
"memo":"",
"confirmations":17101
}
]
}
Terra bridge need to register the terra transaction to bridge API, then bridge will process this terra transaction. Only need post transaction data from terra to fantom.
Post data to this API endpoint:https://bridgeapi.anyswap.exchange/v3/records
const data = {
hash: hash,
srcChainID: srcChainID,
destChainID: destChainID,
from: from,
version: swapin,
value: value,
to: to,
symbol: symbol,
pairid: pairid
}
Example:
const data = {
hash: ‘50ebcdd2930168e84f1aeccc1336624ffec35c908a974927342e48a6ab19732d’,
srcChainID: ‘TERRA’,
destChainID: ‘250’,
from: ‘terra1vy9dkernemzq654c6ykwj866gzgx8jnyq74jd0’,
version: ‘swapin’,
value: ‘100000000’,
to: ‘0x94ae7192bfc5f578ca26c4c567f57e9654957603’,
symbol: ‘UST’,
pairid: ‘ustv5’
}