useTransferToken
Description
Hook for transferring ERC20 tokens to an existing wallet.
Parameters
| Name | Type | Description |
|---|---|---|
| to | string | The address of the account to receive the tokens. |
| amount | number | The amount of tokens to transfer. |
| [overrides] | Overrides | Optional 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 });
}