Skip to main content

useTransferToken() function

This feature is currently in beta and may change based on feedback that we receive.

Use this to transfer tokens on your contract

Example

const Component = () => {
const {
mutate: transferTokens,
isLoading,
error,
} = useTransferToken(">>YourERC20ContractInstance<<");

if (error) {
console.error("failed to transfer tokens", error);
}

return (
<button
disabled={isLoading}
onClick={() => transferTokens({ to: "0x...", amount: 1000 })}
>
Transfer
</button>
);
};

Signature:

export declare function useTransferToken(
contract: RequiredParam<Erc20>,
): import("@tanstack/react-query").UseMutationResult<
Omit<
{
receipt: import("@ethersproject/abstract-provider").TransactionReceipt;
data: () => Promise<unknown>;
},
"data"
>,
unknown,
TokenParams,
unknown
>;

Parameters

ParameterTypeDescription
contractRequiredParam<Erc20>an instance of a contract that extends the ERC20 spec (token, token drop, custom contract that follows the ERC20 spec)

Returns:

import("@tanstack/react-query").UseMutationResult<Omit<{ receipt: import("@ethersproject/abstract-provider").TransactionReceipt; data: () => Promise<unknown>; }, "data">, unknown, TokenParams, unknown>

a mutation object that can be used to transfer tokens