Skip to main content

Send ERC-20 token transfers

On EVM networks, you can transfer ERC-20 tokens (USDC, USDT, DAI, etc.) using the transferToken() method on an EVM connector. The flow is identical to native transfers — create a transaction, set the fee, and broadcast.

Example

import { importWallet, ChainGate } from 'chaingate'

const wallet = importWallet({ phrase: 'your phrase here...' })
const cg = new ChainGate({ apiKey: 'your-api-key' })

const ethereum = cg.connect(cg.networks.ethereum, wallet)

// Get token balances to find the amount
const tokens = await ethereum.addressTokenBalances()
const usdc = tokens.find(t => t.symbol === 'USDC')

if (usdc) {
// Transfer ERC-20 tokens
const tx = await ethereum.transferToken(
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC contract address
usdc, // Amount to send
'0xRecipient...' // Recipient address
)

const fees = tx.recommendedFees()
tx.setFee(fees.normal)
const broadcasted = await tx.signAndBroadcast()
console.log('TX ID:', broadcasted.transactionId)
}

Parameters

ParameterTypeDescription
contractAddressstringThe ERC-20 token contract address (with 0x prefix)
amountAmountThe token amount to transfer
toAddressstringThe recipient address
options?AddressOptionsOptional: { index, derivationPath }

Custom EVM RPC networks

transferToken() also works on custom EVM RPC networks:

const bsc = cg.networks.evmRpc({
rpcUrl: cg.rpcUrls.bsc,
chainId: 56,
name: 'BNB Smart Chain',
symbol: 'BNB',
})

const connector = cg.connect(bsc, wallet)
const tx = await connector.transferToken(
'0x55d398326f99059fF775485246999027B3197955', // USDT on BSC
'100', // Amount in token decimals
'0xRecipient...'
)

Key points

  • Same flow as native transfers: transferToken() returns a transaction — use setFee() and signAndBroadcast().
  • All EVM networks: Available on both native EVM connectors and custom EVM RPC connectors.
  • Gas fees in native coin: Token transfers still require the network's native coin (ETH, BNB, etc.) to pay gas fees.
  • View token balances: Use connector.addressTokenBalances() to see all ERC-20/ERC-721/ERC-1155 tokens (native EVM networks only).