Docs

useTransferNFT

Hook for transferring ERC721 or ERC1155 NFTs to another wallet address.

Available to use on contracts that implement either the ERC721 and ERC1155 interfaces, such as the Edition or NFT Collection .

The wallet address that initiates this transaction must have transfer permissions on the contract (i.e. the tokens are not soulbound). It also must have the required amount of token(s) available to transfer.

Example

import { useContract, useTransferNFT, Web3Button } from "@thirdweb-dev/react";
// Your NFT collection contract address
const contractAddress = "{{contract_address}}";
const walletAddress = "{{wallet_address}}";
const tokenId = "{{token_id}}";
function App() {
// Contract must be an ERC-721 or ERC-1155 contract
const { contract } = useContract(contractAddress);
const {
mutateAsync: transferNFT,
isLoading,
error,
} = useTransferNFT(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
transferNFT({
to: walletAddress, // Address to transfer the token to
tokenId: tokenId, // Token ID to transfer
})
}
>
Transfer
</Web3Button>
);
}

Parameters

Returns

Mutation object to transfer NFTs

const { mutateAsync, isLoading, error } = useTransferNFT(contract);

options

The mutation function takes an object with the following properties:

to

The wallet address to transfer the token(s) to.

To use the connected wallet address, use the useAddress hook.

tokenId

The token ID of the NFT to transfer.

Can be a string or number .

amount (ERC1155 only)

If you are using an ERC1155 contract, specify the amount of tokens to transfer.