🌉
Celer cBridge
  • 👋Welcome to cBridge
  • Introduction
    • Architectural Benefits
    • State Guardian Network
    • SGN and cBridge
      • The SGN as a cBridge node gateway and Service Level Agreement (SLA) arbitrator
      • The SGN as a Shared Liquidity Pool Manager
    • Fungible Token Bridging Models
    • cBridge Security
  • Tutorial
    • Cross-chain Transfer
    • LP Guide
    • SGN V2 Staking Guide
    • SGN V1 Unbonding Guide
    • Smart Contract as LP
    • Aptos Bridging Guide
    • Ape Chain Bridging Guide
    • Flow Cadence Bridging Guide
    • Flow EVM Bridging Guide
  • Developer
    • Circle Cross-chain USDC Transfer Protocol(CCTP)
    • cBridge SDK
    • cBridge Pool-Based Transfer (xLiquidity)
      • Transfer
      • Transfer Refund
    • cBridge Canonical Mapping Transfer (xAsset)
      • Mint
      • Mint Refund
      • Burn
      • Burn Refund
    • cBridge Transfer Web Widget
    • cBridge Aptos Transfer (xAsset Only)
    • Custom Transfer URL Schemes
    • cBridge APIs for Sui
    • Referral Specific Transfer
    • cBridge Limit Parameters
    • API Reference
      • Gateway: GetTransferConfigsForAll
      • Gateway: EstimateAmt
      • Contract: Pool-Based Transfer
      • Gateway: GetTransferStatus
      • Contract: Pool-Based Transfer Refund
      • Gateway: TransferHistory
      • Contract: Mint Canonical Token(OriginalTokenVault)
      • Contract: Mint Canonical Token(OriginalTokenVaultV2)
      • Contract: Mint Canonical Token Transfer Refund
      • Contract: Burn Canonical Token(PeggedTokenBridge)
      • Contract: Burn Canonical Token (PeggedTokenBridgeV2)
      • Contract: Burn Canonical Token Transfer Refund
      • Gateway: MarkRefRelation
      • Contract: TransferAgent Mint Token Submission
      • Contract: TransferAgent Burn Token Submission
      • Contract: Aptos Vault Mint Token Submission
      • Contract: Aptos PegBridge Burn Token Submission
  • NFT Bridge
    • Introduction
    • NFT Bridge Fee
  • List Your Tokens
    • Simple Listing Process
  • Reference
    • FAQ
    • Audit Reports
    • Contract Addresses
Powered by GitBook
On this page
  • Implementation
  • Request Parameters
  • TransferId Generation
  • Response
  1. Developer
  2. API Reference

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

PreviousGateway: EstimateAmtNextGateway: GetTransferStatus

Last updated 1 year ago

Implementation

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

Here is the abi for Bridge:

  • 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

If receiver is a smart contract and the token you are sending is a wrapped native gas token on the destination chain, make sure the contract can receive native gas token by implementing fallback / receive functions.

TransferId Generation

const transfer_id = ethers.utils.solidityKeccak256(
     [
      "address",
      "address",
      "address", 
      "uint256", 
      "uint64", 
      "uint64", 
      "uint64"
     ], 
     [
      "0xdad9d86885d217b92a47370e1e785897dd09a4f3", /// User's wallet address, 
      "0xdad9d86885d217b92a47370e1e785897dd09a4f3", /// User's wallet address, 
      "0x7d43aabc515c356145049227cee54b608342c0ad", /// Wrap token address/ ERC20 token address 
      "10000000000", /// Send amount in String 
      "5", /// Destination chain id
      "1638862397751", /// Nonce
      "4002", /// Source chain id
     ],
)

Response

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

Use the value given by

If you want to use a max_slippage with your own calculation, please make sure it is not less than given by cBridge contract. Otherwise, the transaction will fail.

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

Bridge
send
sendNative
refund process
https://github.com/celer-network/cBridge-typescript-client/tree/main/contract/abi/Bridge.sol
minimalMaxSlippage
getTransferStatus
amount estimation