Bridge SDK
import {Bridge} from 'navi-sdk'
config(config)
Service configuration.
Params:
config.apiKey
string
getSupportChains()
Get all chains supported for cross-chain swap.
Example:
const chains = await Bridge.getSupportChains();
Example Output:
[{
"id": 0,
"wChainId": 1,
"name": "solana",
"iconUrl": "https://statics.mayan.finance/assets/SOL.png",
"nativeCurrency": {
"address": "0x0000000000000000000000000000000000000000",
"chain": "0",
"decimals": 9,
"logoURI": "https://statics.mayan.finance/assets/SOL.png",
"name": "SOL",
"symbol": "SOL"
},
"rpcUrls": {
"default": "https://rpc.hellomoon.io/2b0c2256-c914-45f6-b720-1e88d12ae55a"
},
"blockExplorers": {
"default": {
"url": "https://explorer.solana.com/",
"name": ""
}
}
}]
getSuppportTokens(chainId, page, pageSize)
Get the tokens supported by the specified chain.
Params:
chainId
number
chain id.
You can query the chain ID through getSupportChains().
page
number
default 1.
pageSize
number
default 100.
Example:
// Get the tokens supported by Solana.
const tokens = await Bridge.getSuppportTokens(0, 1, 20)
Example output:
[{
"address": "0x0000000000000000000000000000000000000000",
"addressInbrowser": "So11111111111111111111111111111111111111112",
"decimals": 9,
"logoURI": "https://statics.mayan.finance/SOL.png",
"name": "SOL",
"symbol": "SOL",
"chainId": 0,
"chainName": "solana",
"isSuggest": false,
"isVerify": true,
"category": []
}]
searchSupportTokens(chainId, keyword)
Query the tokens supported by the specified chain, supporting queries by name, address, and symbol.
Params:
chainId
number
chain id. You can query the chain ID through getSupportChains().
keyword
string
name, address, and symbol.
Example:
// Search NAVX in Sui Chain
const tokens = await Bridge.searchSupportTokens(1999, 'NAVX')
Example output:
[{
"address": "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
"addressInbrowser": "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
"decimals": 9,
"logoURI": "https://arweave.net/FNGKLRGBS7D4lXxsmz4_F-xkMQs9DIRsTQT_q0Nn-iI",
"name": "NAVX",
"symbol": "NAVX",
"isSuggest": false,
"isVerify": true,
"chainId": 1999,
"chainName": "sui",
"category": []
}]
getQuote(from, to, amount, options)
Retrieves a quote and the route for swapping one coin to another.
Params:
from
Token
Source token. You can query token through searchSupportTokens().
to
Token
Dest token. You can query token through searchSupportTokens().
amount
number | string
amout of source token
options.slippageBps
number
slippage setting
options.referrerBps
number
referrer fee setting
Example:
const quote = Bridge.getQuote(NAVX, SOL, 1000, {
slippageBps: 50
})
Example output:
{
"routes": [
{
"provider": "Mayan",
"amount_in": "1000",
"slippage_bps": 50,
"amount_out": "0.503874440",
"min_amount_out": "0.501355067",
"spend_duration": 60,
"total_fee": "1.004759760",
"info_for_bridge": {},
"from_token": {
"address": "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
"chain": "1999",
"decimals": 9,
"logoURI": "https://arweave.net/FNGKLRGBS7D4lXxsmz4_F-xkMQs9DIRsTQT_q0Nn-iI",
"name": "NAVX",
"symbol": "NAVX"
},
"to_token": {
"address": "0x0000000000000000000000000000000000000000",
"chain": "0",
"decimals": 9,
"logoURI": "https://statics.mayan.finance/SOL.png",
"name": "SOL",
"symbol": "SOL"
},
"path": [
{
"token": "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
"amount": "1000"
},
{
"token": "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
"amount": "62.736334040"
},
{
"token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "62.736334040"
},
{
"token": "0x0000000000000000000000000000000000000000",
"amount": "0.503874440"
}
]
}
]
}
swap(quote, fromAddress, toAddress, walletConnection, referrerAddresses)
Perform cross-chain transaction.
Params:
quote
Quote
Cross-chain routing and configuration. You can get quote through getQuote().
fromAddress
string
Wallet address in source chain.
toAddress
string
Wallet address in dest chain. This address will receive dest token。
walletConnection
WalletConnection
Configuration of wallet connections for different chains. Used for signing, on-chain data queries, and submitting transactions.
referrerAddresses
{ sui: string; evm: string; solana: string; }
Wallet address for receiving referrer fees.
Example:
const tranasction = await Bridge.swap(quote, '0x00', '0x00', walletConnection)
Example output:
{
"id": "0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1",
"status": "processing",
"lastUpdateAt": "2025-03-12T08:30:48.528Z",
"sourceChainId": 137,
"destChainId": 1999,
"walletSourceAddress": "0x93731F699A89a02648D5ADe6632b061a659A7836",
"walletDestAddress": "0xc41d2d2b2988e00f9b64e7c41a5e70ef58a3ef835703eeb6bf1bd17a9497d9fe",
"totalFeeAmount": 1.017618,
"sourceToken": {
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"symbol": "POL",
"decimals": 18,
"logoURI": "https://statics.mayan.finance/polygon.png",
"price": 0.99992766
},
"destToken": {
"address": "0x2::sui::SUI",
"symbol": "SUI",
"decimals": 9,
"logoURI": "https://cdn.mayan.finance/sui_coin.png",
"price": 2.47830117
},
"hasSwap": false,
"bridgeProvider": "mayan",
"bridgeStatus": "completed",
"bridgeFromToken": {
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"symbol": "POL",
"decimals": 18,
"logoURI": "https://statics.mayan.finance/polygon.png",
"price": 0.99992766
},
"bridgeToToken": {
"address": "0x2::sui::SUI",
"symbol": "SUI",
"decimals": 9,
"logoURI": "https://cdn.mayan.finance/sui_coin.png",
"price": 2.47830117
},
"bridgeFromAmount": "15",
"bridgeToAmount": "1.090041253",
"bridgeStartAt": "2025-03-05T05:11:49.000Z",
"bridgeEndAt": "2025-03-05T05:21:13.064Z",
"bridgeSourceTxHash": "0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1",
"bridgeDestTxHash": "6cWBvqKwj3rTCbiP7ck5Uo6qtRx1Tshc9qxBibFH6fGi",
"bridgeRefundTxHash": null,
"explorerLink": "https://explorer.mayan.finance/tx/MCTP_0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1__0"
}
getTransaction(id)
Query transaction information for the specified ID(tx hash).
Params:
id
string
transaction id.(tx hash)
Example:
const transaction = await Bridge.getTransaction("0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1")
Example output:
{
"id": "0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1",
"status": "completed",
"lastUpdateAt": "2025-03-12T08:30:48.528Z",
"sourceChainId": 137,
"destChainId": 1999,
"walletSourceAddress": "0x93731F699A89a02648D5ADe6632b061a659A7836",
"walletDestAddress": "0xc41d2d2b2988e00f9b64e7c41a5e70ef58a3ef835703eeb6bf1bd17a9497d9fe",
"totalFeeAmount": 1.017618,
"sourceToken": {
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"symbol": "POL",
"decimals": 18,
"logoURI": "https://statics.mayan.finance/polygon.png",
"price": 0.99992766
},
"destToken": {
"address": "0x2::sui::SUI",
"symbol": "SUI",
"decimals": 9,
"logoURI": "https://cdn.mayan.finance/sui_coin.png",
"price": 2.47830117
},
"hasSwap": false,
"bridgeProvider": "mayan",
"bridgeStatus": "completed",
"bridgeFromToken": {
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"symbol": "POL",
"decimals": 18,
"logoURI": "https://statics.mayan.finance/polygon.png",
"price": 0.99992766
},
"bridgeToToken": {
"address": "0x2::sui::SUI",
"symbol": "SUI",
"decimals": 9,
"logoURI": "https://cdn.mayan.finance/sui_coin.png",
"price": 2.47830117
},
"bridgeFromAmount": "15",
"bridgeToAmount": "1.090041253",
"bridgeStartAt": "2025-03-05T05:11:49.000Z",
"bridgeEndAt": "2025-03-05T05:21:13.064Z",
"bridgeSourceTxHash": "0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1",
"bridgeDestTxHash": "6cWBvqKwj3rTCbiP7ck5Uo6qtRx1Tshc9qxBibFH6fGi",
"bridgeRefundTxHash": null,
"explorerLink": "https://explorer.mayan.finance/tx/MCTP_0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1__0"
}
getWalletTransactions(address, page, limit)
Query cross-chain transactions for the specified address.
Params:
address
string
wallet address.
page
number
default 1
limit
number
default 10
Example:
const transactions = await Bridge.getWalletTransactions("0x93731F699A89a02648D5ADe6632b061a659A7836", 1, 10)
Example output:
[{
"id": "0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1",
"status": "completed",
"lastUpdateAt": "2025-03-12T08:30:48.528Z",
"sourceChainId": 137,
"destChainId": 1999,
"walletSourceAddress": "0x93731F699A89a02648D5ADe6632b061a659A7836",
"walletDestAddress": "0xc41d2d2b2988e00f9b64e7c41a5e70ef58a3ef835703eeb6bf1bd17a9497d9fe",
"totalFeeAmount": 1.017618,
"sourceToken": {
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"symbol": "POL",
"decimals": 18,
"logoURI": "https://statics.mayan.finance/polygon.png",
"price": 0.99992766
},
"destToken": {
"address": "0x2::sui::SUI",
"symbol": "SUI",
"decimals": 9,
"logoURI": "https://cdn.mayan.finance/sui_coin.png",
"price": 2.47830117
},
"hasSwap": false,
"bridgeProvider": "mayan",
"bridgeStatus": "completed",
"bridgeFromToken": {
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"symbol": "POL",
"decimals": 18,
"logoURI": "https://statics.mayan.finance/polygon.png",
"price": 0.99992766
},
"bridgeToToken": {
"address": "0x2::sui::SUI",
"symbol": "SUI",
"decimals": 9,
"logoURI": "https://cdn.mayan.finance/sui_coin.png",
"price": 2.47830117
},
"bridgeFromAmount": "15",
"bridgeToAmount": "1.090041253",
"bridgeStartAt": "2025-03-05T05:11:49.000Z",
"bridgeEndAt": "2025-03-05T05:21:13.064Z",
"bridgeSourceTxHash": "0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1",
"bridgeDestTxHash": "6cWBvqKwj3rTCbiP7ck5Uo6qtRx1Tshc9qxBibFH6fGi",
"bridgeRefundTxHash": null,
"explorerLink": "https://explorer.mayan.finance/tx/MCTP_0xafd4beab46cad17bc0f95c23572c9d103724389a53b7ea0635c770ed1450f6d1__0"
}]
Last updated