A token transfer transaction moves ERC-20 tokens from one account to another.
This guide uses an ERC-20 transfer (USDC) as a reference example. Replace the
token, decimals, and amount for your asset.
1) Set up the client and signer
Create the SDK client and signer used for approvals.
import { DenClient } from "@onchainden/mls-sdk-ts";import { privateKeyToAccount } from "viem/accounts";import { encodeAbiParameters, encodeFunctionData, type Hex } from "viem";const signer = privateKeyToAccount("0xYOUR_PRIVATE_KEY");const client = new DenClient({ apiKey: process.env.DEN_API_KEY!, baseUrl: process.env.DEN_API_BASE_URL!,});
2) Build the transfer data
Encode the ERC-20 transfer call data for the token transfer.