Ask or search…
K
Links

Transfer your NFT

An NFT, or Non-Fungible Token, is a unique digital asset that represents ownership or proof of authenticity for a specific item, like a piece of digital artwork, a collectible, or even a virtual property. Transferring an NFT means changing the ownership of that digital item from one person to another.
Imagine you have a one-of-a-kind digital trading card that you'd like to give to a friend. To do this, you would initiate a transfer, which is similar to handing over a physical item to someone else. In the digital world, this transfer process is recorded on a blockchain, a secure and transparent digital ledger that keeps track of every transaction made.
When you transfer an NFT, you're essentially updating the blockchain record to show that your friend is now the new owner of the digital trading card. Once the transfer is complete, your friend has full control over the NFT and can choose to keep it, sell it, or trade it with others. This process ensures that ownership is securely and transparently tracked, preventing counterfeiting or unauthorized duplication of the digital item.
MetaMask is designed as a browser extension to provide a user-friendly interface and secure key management for interacting with dApps and web services. Connecting from Node.js is not supported because MetaMask focuses on end-user interactions within web browsers, while Node.js is a server-side JavaScript runtime typically used for backend development.

How to perform an NFT transfer with MetaMask from your browser-based application

Use the TatumSDK (@tatumcom/js) to prepare, sign and broadcast the transaction using MetaMask.
You will leverage the WalletProvider submodule, which includes multiple browser-based wallet extensions. MetaMask is just one of them.
TypeScript
JavaScript
1
// yarn add @tatumio/tatum
2
import {TatumSDK, Network, Ethereum, MetaMask} from '@tatumio/tatum'
3
4
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
5
6
//This is the BoredApeYachtClub NFT token address
7
const BAYC = '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D'
8
9
const txId: string = await tatum.walletProvider.use(MetaMask).transferNft('0x4675C7e5BaAFBFFbca748158bEcBA61ef3b0a263', '123', BAYC)
10
11
console.log(txId)
12
13
// We have prepared a transfer of NFT BAYC#123 from your default connected MetaMask account to the recipient - 0x4675C7e5BaAFBFFbca748158bEcBA61ef3b0a263
1
// Install with: npm install @tatumio/tatum
2
const { TatumSDK, Network, MetaMask } = require("@tatumio/tatum");
3
4
(async () => {
5
try {
6
const tatum = await TatumSDK.init({ network: Network.ETHEREUM });
7
//This is the BoredApeYachtClub NFT token address
8
const BAYC = '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D'
9
10
const txId = await tatum.walletProvider.use(MetaMask).transferNft('0x4675C7e5BaAFBFFbca748158bEcBA61ef3b0a263', '123', BAYC);
11
console.log(txId);
12
} catch (error) {
13
console.error("Error signing a transaction using MetaMask:", error);
14
}
15
})();
16
17
// We have prepared a transfer of NFT BAYC#123 from your default connected MetaMask account to the recipient - 0x4675C7e5BaAFBFFbca748158bEcBA61ef3b0a263
18
// Result is a transaction IF of a broadcasted transaction

Request parameters

  • recipient - string, recipient of your transaction
    • Example: "0x4675C7e5BaAFBFFbca748158bEcBA61ef3b0a263"
  • tokenId - string, token ID to be sent, always in a token currency like USDT
    • Example: "1.5"
  • tokenAddress - string, token address of a NFT collection you want to transfer
    • Example: "0xdAC17F958D2ee523a2206206994597C13D831ec7"

Response

  • txId - string, transaction hash of signed and broadcasted transaction
    • Example: "0xdb1e03f4cea29265f031bfc0514b07c15a5fc5e5cc2fd47f7d9a54c74f5c5637"
© Tatum Technology, LLC