JS SDK Bridging
Symbiosis JS SDK Bridging
The Symbiosis protocol uses minting/burning mechanisms to implement cross-chain operations (cross-chain swaps, interchain communicating, cross-chain zaps, bridging).
Bridging is a process of
  • Minting sTokens on one blockchain from stablecoins from another blockchain or
  • Burning sTokens on one blockchain to obtain stablecoins on another blockchain.
You can find an explanation of what happens during bridging in the document Mint-Burn Process | Symbiosis
Symbiosis JS SDK implements one method for bridging: exactIn that takes the following parameters for input:
An object of TokenAmount type. An amount of tokens (stablecoins or sTokens) the user gives away.
The token the user expects to receive
The recipient's address. Usually, it is identical to the sender's address but can differ.
The address that can revert this operation if this operation gets stuck. Usually, it is identical to the sender's address but can differ.
Please check out Emergencies for more information on stuck operations.
const bridging = symbiosis.newBridging()
const { execute, fee, tokenAmountOut } = await bridging.exactIn(
const { response, waitForMined } = await execute(signer)
const { receipt, waitForComplete } = await waitForMined()
const log = await waitForComplete()
The method exactIn returns:
A function to execute the bridging operation. Calling this function triggers the bridging transaction signing and sends the signed transaction to the origin blockchain. Accepts an object of Signer type.
An object of TokenAmount type. The amount of tokens to pay the fee for bridging: the fee for relayers network work. Please refer to Relayers Network | Symbiosis for more information on relayers.
An object of TokenAmount type. An amount of tokens the user gets on the destination's blockchain.
Instance of TransactionRequest type used in the stateless mode.
Calling the execute function returns:
  • An object response of TransactionResponse type
  • A function waitForMined is a function of waiting for the transaction to be mined.
Calling the waitForMined function returns:
  • An object receipt of TransactionReceipt type
  • A function waitForComplete is a function of waiting for getting tokens on the destination blockchain.
The stateless mode (since JS SDK v2.3)
const bridging = symbiosis.newBridging()
// transactionRequest contains everything you need to send a transaction by yourself
const { transactionRequest } = await bridging.exactIn(...)
// Send the transaction and get a receipt
const receipt = ...
// Wait for the transaction to be completed on the destination chain
const log = await bridging.waitForComplete(receipt)
Copy link