useTransferNativeToken

A hook to transfer native token (of the active chain) to another wallet

Example

const Component = () => {
const {
mutate: transferNativeToken,
isLoading,
error,
} = useTransferNativeToken();
if (error) {
console.error("failed to transfer tokens", error);
}
return (
<button
disabled={isLoading}
onClick={() =>
transferNativeToken({
to: "{{wallet_address}}",
amount: "0.1",
})
}
>
Transfer
</button>
);
};
function useTransferNativeToken(): UseMutationResult<
Omit<TransactionResultWithMetadata<unknown>, "data">,
unknown,
unknown
>;

Returns

let returnType: UseMutationResult<
Omit<TransactionResultWithMetadata<unknown>, "data">,
unknown,
unknown
>;

A Mutation object to transfer native tokens

const { mutateAsync, isLoading, error } = useTransferNativeToken();

options

The mutation function takes an object containing to and amount properties.

  • to - The wallet address to transfer tokens to. Must be a string .

  • amount - The amount of tokens to transfer. Must be a number .