Skip to main content
We have some convenience tools for transfering a chain’s native gas token or ERC-20s. For transferring tokens, you’ll need to fund your wallet with the desired tokens. You can always see your wallets and get their addresses in the dashboard at https://app.goldsky.com/dashboard/compose/{appName}. You can see the full documents of the transfer function at Wallets.

Examples

/// <reference types="../.compose/types.d.ts" />

export async function main(
  { evm }: TaskContext,
  _args: any
) {

  // transfer erc20
  const usdc = await new evm.ERC20(evm.chains.base, env.USDC_ADDRESS, wallet);
  await usdc.transfer(amount, env.RECIPIENT);

  // transfer native gas tokens
  wallet.transfer(evm.chains.base, amount, env.RECIPIENT);
}

Interface

Here’s the full interface for evm.ERC20
interface ERC20 {
  constructor: (chain: Chain, address: string, wallet: IWallet);
  transfer: (address: string; amount: string) => Promise<{ hash: string }>;
  balanceOf(address: string) => Promise<string>;
  allowance(address: string, address: string) => Promise<string>;
  approve(address: string, amount: string) => Promise<{ hash: string }>;
  transferFrom(address: string, address: string, amount: string) => Promise<{ hash: string }>;
}