nearprotocolnear

How do you send or transfer an NFT to another account on NEAR protocol?


The goal is to send another user's account the NFT from an account I control. The NFT follows the standard, but it appears that wallets do not support this feature in their UIs now so we have to execute a shell command to effect the transfer. How is this done?


Solution

  • If the contract adheres to the NEP-171 standard, then you can use the near-cli and call nft_transfer. You also need to use the mainnet, and login to the wallet. Caller of the method must attach a deposit of 1 yoctoNear for security purposes (see requirements for more details)

    export NEAR_ENV=mainnet
    near login
    near call contractName nft_transfer '{"receiver_id": "someNearAccount", "token_id": "someTokenId"}' --accountId yourAccountId --depositYocto 1
    

    Now, if the call returns without any errors, the NFT should have been transferred. In the terminal, you also get a link to the explorer to see the transaction. You can also call another method nft_token, to see the updated information:

    near view contractName nft_token '{"tokenId": "someTokenId"}'
    

    You'll see that the owner_id has changed.