PixelBridge Core
  • What is PixelBridge Core?
  • ⚪PRODUCT
    • How does PixelBridge Core work?
      • Fees
      • Messaging protocols
      • PixelBridge Core contracts
      • Token value
      • Liquidity provision
    • PixelBridge Core guide
    • How to provide liquidity?
    • How to bridge with PixelBridge Core via mobile TronLink
    • Security audit
  • ⚪PixelBridge CORE SDK
    • Get started
    • Guides
      • General
        • Token info
        • Send
        • Swap
        • Paying fees with stables
      • EVM
        • Transfer
        • Allowance and approve
      • Solana
        • Transfer
        • Swap
      • Stellar
        • Transfer
      • Utilities
        • Amount and fee calculations
        • Transfer time
        • Extra gas limits
  • ⚪SOCIAL LINKS
    • Twtter
    • Telegram
    • Medium
  • ⚪PixelBridge ECOSYSTEM
    • PixelBridge Classic
    • PixelBridge BaaS
Powered by GitBook
On this page
  1. ⚪PixelBridge CORE SDK
  2. Guides
  3. EVM

Transfer

Approve the token transfer

Before sending tokens, the bridge has to be authorized to use the tokens of the owner. This is done by calling the approve method on the SDK instance.

For Ethereum USDT (due to the specifics of the USDT contract): If the current allowance is not 0, this function will perform an additional transaction to set the allowance to 0 before setting the new allowance value.

Copy

const rawTransactionApprove = await sdk.bridge.rawTxBuilder.approve({
  token: sourceToken,
  owner: accountAddress,
});
const approveTxReceipt = await sendRawTransaction(rawTransactionApprove as RawEvmTransaction);
console.log("approve tx id:", approveTxReceipt.transactionHash);

Send Tokens

Initiate the raw transaction of token transfer with the SDK instance:

Copy

const rawTransaction = sdk.bridge.rawTxBuilder.send({
  amount: "1.01",
  fromAccountAddress: fromAddress,
  toAccountAddress: toAddress,
  sourceToken: sourceToken,
  destinationToken: destinationToken,
  messenger: Messenger.PixelBridge,
});
const txReceipt = await sendRawTransaction(rawTransactionApprove as RawEvmTransaction);
console.log("tx id:", txReceipt.transactionHash);
PreviousEVMNextAllowance and approve

Last updated 12 months ago