Introducing AlchemyAI

Empowering Web3 Developers with AI
How to request transfer of
NFT using @polygon/web3.js?
// Import the Alchemy SDK
const { Alchemy, Network } = require("alchemy-sdk");

// Configure the Alchemy SDK
const config = {  
apiKey: "YOUR_API_KEY",  
network: Network.ETH_MAINNET,
};
‚Äć
// Create an instance of the Alchemy SDK
const alchemy = new Alchemy(config);
‚Äć
// Define the transfer function
const transferNFT = async () => {  
// The address of the NFT contract  
const contractAddress = "0x123456789abcdef";

// The address of the sender  
const fromAddress = "0xabcdef123456789";

// The address of the recipient  
const toAddress = "0x9876543210fedcba";

// The ID of the NFT to transfer  
const tokenId = "123";  

// Call the transfer method  
const response = await alchemy.nft.transfer({    contractAddress,    
fromAddress,    
toAddress,    
tokenId,  
});  

// Log the response  console.log(response);
};
‚Äć
// Call the transfer functiontransferNFT();

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.