Transfer an NFT
This document assumes you have followed the deploy a contract and the mint an NFT instructions, and you have another user account for transferring an NFT.
Transfer an NFT
Add another user's details
Add a new environment variable to the .env
file.
TRANSFER_TO=<SECOND_USER_ETHEREUM_ADDRESS>
Make the transfer
Load the existing contract, then call the transfer
method of the SDK to transfer a specific NFT, defined by tokenId
, to the TRANSFER_TO
address.
const existing = await sdk.loadContract({
template: TEMPLATES.ERC721Mintable,
contractAddress: "<EXISTING_CONTRACT_ADDRESS>",
});
const transferTo = await existing.transfer({
from: process.env.WALLET_PUBLIC_ADDRESS,
to: process.env.TRANSFER_TO,
tokenId: 0,
});
const transfered = await transferTo.wait();
console.log(
`Status: ${transfered.status}\n NFT transfered on ${transfered.blockHash} with ${transfered.confirmations} confirmation!`,
);
Example output:
Status: 1
NFT transfered on 0xde6603f8dbba027d2210648c39c763cfc268adffa49146d14cb23db1e27f1991 with 1 confirmation!
Verify with Etherscan
Go to https://goerli.etherscan.io/ and add the recipients address.