Skip to main content
Send ERC-20 tokens using the embedded wallet by encoding the transfer function call.

Implementation

Key concepts

  • ERC-20 ABI - Minimal ABI containing only the transfer function
  • Function encoding - Uses encodeFunctionData from viem to encode the function call
  • Amount handling - Amount should be in the token’s smallest unit (considering decimals)
  • Contract interaction - Sends transaction to the token contract address with encoded data

Important notes

The amount should be specified in the token’s smallest unit. For a token with 18 decimals, to send 1 token, you’d specify 1000000000000000000 (1 × 10^18).
Make sure the user has approved your contract to spend tokens if you’re building a dApp that needs to transfer tokens on behalf of users.

Next steps

NFT Minting

Learn how to mint NFTs

Multi-Step Flow

Handle approve + transfer flows