Skip to main content

useTransferToken

Description

Hook for transferring ERC20 tokens to an existing wallet.

Parameters

NameTypeDescription
tostringThe address of the account to receive the tokens.
amountnumberThe amount of tokens to transfer.
[overrides]OverridesOptional overrides for the contract call.

Example

import { useContract, useTransferToken } from "@openformat/react";

// address of a created token (ERC20) contract. You can get this from the subgraph.
const address = "0x123...";
const amount = 1;

// returns an instance of the token contract.
const { data: token } = useContract(address);

const { data, transfer } = useTransferToken(token);

async function handleTransfer() {
await transfer({ to: "0x123...", amount: amount });
}