🟧
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 Symbiosis Mint-Burn Process
Symbiosis JS SDK implements one method for bridging
:
exactIn
that takes the following parameters for input:Property | Description |
---|---|
tokenAmountIn | |
tokenOut | The token the user expects to receive |
to | The recipient's address. Usually, it is identical to the sender's address but can differ. |
revertableAddress | The address that can revert this operation if this operation gets stuck. Usually, it is identical to the sender's address but can differ. |
const bridging = symbiosis.newBridging()
const { execute, fee, tokenAmountOut } = await bridging.exactIn(
tokenAmountIn,
tokenOut,
to,
revertableAddress
)
const { response, waitForMined } = await execute(signer)
const { receipt, waitForComplete } = await waitForMined()
const log = await waitForComplete()
The method
exactIn
returns:Property | Description |
---|---|
execute | A function to execute the bridging operation. Calling this function triggers the bridging transaction signing and sends the signed transaction to the source blockchain. Accepts an object of Signer type. |
fee | 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. |
tokenAmountOut | |
transactionRequest |
Calling the
execute
function returns: - A function
waitForMined
is a function of waiting for the transaction to be mined.
Calling the
waitForMined
function returns: - 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)
Last modified 13d ago