Contract: Pool-Based Transfer

Trigger cBridge contract `send` function to move user's assets to cBridge contract on source chain. Then cBridge gateway and Celer SGN will send assets to the user's asset on the destination chain

Implementation

Pool-based transfers are done via the Bridgearrow-up-right contract, specifically via the sendarrow-up-right or sendNativearrow-up-right functions. For advanced users, these two functions can be called from smart contracts, but please read the refund process before you proceed.

Here is the abi for Bridge: arrow-up-righthttps://github.com/celer-network/cBridge-typescript-client/tree/main/contract/abi/Bridge.solarrow-up-right

  • Transfer gas token(ETH): sendNative. No need to provide token address

  • Transfer ERC20 token: send. Token address is needed

/// SendNative
const transferTx = await transactor(
     bridge.sendNative(
     "0xaa47c83316edc05cf9ff7136296b026c5de7eccd", /// User's wallet Address
     100000000, /// Transfer amount with decimal
     4002, /// Destination chain id
     1638864397751, /// Nonce
     3000, /// Max slippage
     { 
          value: 100000000, /// Same amount as above
     },
     ),
).catch(e => {
     /// Handle Error
});

/// Send
const transferTx = await transactor(
     bridge.send(
     "0xdad9d86885d217b92a47370e1e785897dd09a4f3", /// User's Wallet Address
     "0x7d43aabc515c356145049227cee54b608342c0ad", /// Selected Token Address
     10000000000, /// Transfer amount with decimal
     5, /// Destination chain id
     1638862397751, /// Nonce
     780, /// Max slippage
     ),
).catch(e => {
     /// Handle Error
});

Request Parameters

Name
Type
Description

receiver

String

User's wallet address

token

String

Token's address on source chain

amount

BigNumber

Token amount to be sent

dst_chain_id

BigNumber

Destination chain id

nonce

BigNumber

Current timestamp

max_slippage

BigNumber

Use the value given by amount estimation

circle-exclamation
circle-exclamation

TransferId Generation

When you submit on-chain send transaction, you can also generate a transfer id for future reference. For example, it is used for getTransferStatus and withdrawLiquidityForTransferRefund. It should be the same as transferId inside on-chain transaction log.

Response

Since this function is an Ethereum on-chain transaction, the response is the corresponding transaction response.

Last updated