Contract: Burn Canonical Token(PeggedTokenBridge)

Contract: Burn pegged tokens and unlock original token from cBridge

Implementation

Burning is the reverse of the minting process. Canonical tokens can be burned via the PeggedTokenBridge contract on the source chain, which will trigger the release of the original tokens from the OriginalTokenVault contract on the destination chain. For advanced users, the burn function can be called from smart contracts.

Here is the abi for the canonical / pegged token bridge contracts: https://github.com/celer-network/cBridge-typescript-client/tree/main/contract/abi/pegged/PeggedTokenBridge.sol, https://github.com/celer-network/cBridge-typescript-client/tree/main/contract/abi/pegged/OriginalTokenVault.sol

peggedTokenBridge!.burn(
     pegConfig.config.pegged_token.token.address, 
     value, 
     address, 
     nonce)

Request Parameters

NameTypeDescription

token

String

Pegged token address on the pegged chain

amount

UInt256

Burn amount

withdraw_account

String

User's wallet address

nonce

UInt64

Current timestamp

If withdraw_account 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

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

/// Example transaction: 
/// https://www.oklink.com/en/oec-test/tx/0x56c066218fcfab624d53abeea74486a33c0aa2339bde333d94ccc143a83b98b4?tab=3

const burn_id = ethers.utils.solidityKeccak256(
     [
      "address",
      "address",
      "uint256", 
      "address",
      "uint64", 
      "uint64"
     ], 
     [
      "0x51d36e18e3d32d121a3cfe2f3e5771a6fd53274e", /// User's wallet address, 
      "0x37c92f7f65c40813b9404e9d031126550c39f8a8", /// selectedTokenAddress,
      "20000000000000000000", /// Burn amount in String 
      "0x51d36e18e3d32d121a3cfe2f3e5771a6fd53274e", /// User's wallet address, 
      "....", /// Nonce
      "...", /// Pegged chain id
     ],
)

Please be aware that transfer id generation parameters are different between mint flow and burn flow.

Response

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

Last updated