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 { contract } = useContract(<ContractAddress>);
const {
mutate: transferTokens,
isLoading,
error,
} = useTransferToken(contract);

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

Parameters

ParameterTypeDescription
contractRequiredParam<TokenContract>an instance of a TokenContract

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