Skip to main content

useTransferNFT() function

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

Use this to transfer tokens on your NFTContract

Example

const Component = () => {
const { contract } = useContract(<ContractAddress>);
const {
mutate: transferNFT,
isLoading,
error,
} = useTransferNFT(contract);

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

return (
<button
disabled={isLoading}
onClick={() => transferNFT({ to: "0x...", tokenId: 2 })}
>
Transfer
</button>
);
};

Signature:

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

Parameters

ParameterTypeDescription
contractRequiredParam<TContract>an instance of a NFTContract

Returns:

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

a mutation object that can be used to transfer NFTs