Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Update "EVM Token Transfers" Documentation for SDK V3 #170

Open
@saadahmsiddiqui

Description

@saadahmsiddiqui

The title of the page should be renamed to "EVM Fungible Token Transfers"

Update the page with following content:

Transferring a fungible asset between EVM chains

Transferring assets between EVM-based chains can be achieved using the Sygma SDK. To facilitate the transfer, the following steps are required:

  1. Specify transfer parameters such as amount, recipient address, token, destination chain and use the method createFungibleAssetTransfer from @buildwithsygma/evm to create an instance of FungibleAssetTransfer
  2. Check for any approvals required, and if required sign and broadcast these transactions.
  3. Prepare, sign, and send the Transfer transaction to the Source network node

1. Create and initialize the transfer object

To initialize the asset transfer object, the following parameters are required:

  • An EIP1193 compatible EVM provider
  • Environment variable SYGMA_ENV needs to be set as mainnet or testnet
const fungibleTokenTransfer = await createFungibleAssetTransfer({
  source: 1, // Ethereum Mainnet
  destination: 8453, // Base
  sourceNetworkProvider: eip1193CompatibleProvider,
  resource: "0x0000000000000000000000000000000000000000000000000000000000000002", // ETH Resource ID can be found here: https://github.com/sygmaprotocol/sygma-shared-configuration/blob/0e3470df4935ae3cce8b44f496723070ff3b3d1c/mainnet/shared-config-mainnet.json
  amount: BigInt(1) * BigInt(1e17),
  recipientAddress: "",
  sourceAddress: sourceAddress, // source wallet address
});

2. Send Approval transactions

You can check if approvals are required for your transfer. If there are approvals required for the transfer, you can sign the transaction and send it.

const approvals = await fungibleTokenTransfer.getApprovalTransactions();
for (const approval of approvals) {
  const tx = await wallet.sendTransaction(approval);
  await tx.wait();
}

3. Send transfer transaction

Once all the approvals have been confirmed you can finally send the actual fungible token transfer transaction.

const transfer = await transfer.getTransferTransaction();
const tx = await wallet.sendTransaction(transfer);
await tx.wait();

Checking transaction hash

The response object returned by the sendTransaction method contains a hash property. This transaction hash is logged to the console, and it can be used to look up the transaction on a block explorer.

console.log("Sent transfer with hash: ", tx.hash);

A full example of the above can be found here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions