Contract: Aptos PegBridge Burn Token Submission

Submit burn transaction from Aptos chain

Implementation

You will generate Aptos transaction payload and submit it on-chain

const burnTransactionPayload = {
    arguments: [
      amount, /// Burn token amount with decimal
      destinationChainId.toString(), /// Destination chain id
      Array.from(ethers.utils.arrayify(RECEIVER_ADDRESS)), /// Destination receiver address bytes
      nonce /// timestamp
    ],
    function: `0x${PEGGED_BRIDGE_CONTRACT_ADDRESS}::peg_bridge::burn`,
    type: 'entry_function_payload',
    type_arguments: [BURN_TOKEN_ADDRESS], /// burn token address
  };

Request Parameters

Name
Type
Description

amount

u64

Burn token amount

to_chain_id

u64

Destination chain id

to_addr

vector<U8>

Destination receiver address bytes

nonce

u64

Timestamp

TransferId Generation

Since Aptos uses Big-Endian, you may use BCS provided by Aptos to get serialized data.

import { ethers } from "ethers";

const receiverAddressWithout0x = "..." /// Receiver address on destination chain
const transferId = ethers.utils.solidityKeccak256(
    [
      "bytes32", 
      "string", 
      "uint64", 
      "uint64", 
      `bytes${Math.floor(receiverAddressWithout0x.length / 2)}`, 
      "uint64", 
      "uint64", 
      "bytes32", 
      "string"
    ],
    [
      "...", /// Aptos wallet address as sender, 32-byte hexString
      "..." /// Aptos token address
      "...", /// Transfer amount
      "...", /// Destination chain id
      `0x${receiverAddressWithout0x}`, /// Receiver address which length may vary based on different chains
      "...", /// Nonce
      "12360001", /// Source chain id
      `0x${this.contractAddress}`, /// Aptos contract address, 32-byte hexString
      "peg_bridge", /// hardcoded message 
    ],
);

Response

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

Last updated