Skip to main content

Send Native/ERC20 Transactions

To transfer an ERC20/FUSE with a relay, use the transferToken() method. This method relays the transaction and covers the gas fees for the user, so they don't need to worry about those fees.

You can also subscribe to events related to the token transfer to track its progress. The method takes the following parameters as inputs:

ParameterTypeDescription
tokenAddressaddressThe contract address of the ERC20 token or FUSE
recipientAddressaddressThe recipient's wallet address
amountstringThe amount of tokens to transfer in wei
const tokenAddress = "0x28C3d1cD466Ba22f6cae51b1a4692a831696391A"; // USDC Token address
const to = "RECEIVER_ADDRESS";
const amount = ethers.parseUnits("0.001", 6); // 6 represents the decimals of USDC token in the [contract](https://explorer.fuse.io/address/0x28C3d1cD466Ba22f6cae51b1a4692a831696391A?tab=read_contract)
const res = await fuseSDK.transferToken(tokenAddress, to, amount);

console.log(`UserOpHash: ${res?.userOpHash}`);
console.log("Waiting for transaction...");

const receipt = await res?.wait();
console.log("Transaction Hash:", receipt?.transactionHash);