How to find tokenID for NFT transfer in smart contract

I’m trying to move an NFT from Zed.Run using my smart contract but I’m stuck. The problem is I can’t figure out how to get the tokenID that’s needed for the transfer functions.

I know I need to use either transferFrom or safeTransferFrom methods but both require the tokenID parameter. My contract works fine for regular crypto transfers on different chains like Polygon, Avalanche and Klaytn. But NFT transfers are different and I’m missing something basic here.

Does anyone know how to find the tokenID from an NFT? Is there a specific function call or method I should be using to get this information before attempting the transfer?

To find the tokenID for your NFT on Zed.Run, you can check platforms like OpenSea or directly on Zed.Run’s marketplace where the tokenID is usually shown in the URL or the metadata section when viewing the NFT. If you’re coding, you may utilize web3 libraries to query the blockchain. Using the contract address, you can call balanceOf(ownerAddress) to check how many tokens are owned and then use tokenOfOwnerByIndex(owner, index) to retrieve specific tokenIDs. However, be aware that Zed.Run may not implement the ERC721Enumerable extension, in which case those methods won’t work. An alternative is to scan for Transfer events in the contract using getPastLogs to monitor which tokenIDs have been transferred to your address. The tokenID is permanently recorded on the blockchain during minting, so you should always be able to access it through contract calls or event filtering.

check the NFT’s metadata or just check the marketplace where u got it. like, openSea shows the tokenID in the URL or under properties. if u wanna be risky, u could try calling ownerOf(tokenID) with random numbs but it’s not the best idea. some contracts have tokenByIndex() but not sure if zed supports that.

Hmm, interesting… so you’re working with zed.run NFTs specifically? I’ve hit similar roadblocks when I first started with NFT transfers.

The tokenID is just the unique identifier for each individual NFT in the collection - think of it as the “serial number” for that specific horse.

Here’s what I’m curious about - do you already own the NFT you’re trying to transfer? If you do, you should see the tokenID in your wallet or on whatever marketplace you bought it from. Most wallets like MetaMask show token details when you click on the NFT.

Also, are you transferring an NFT that your contract owns, or building something where users transfer their own NFTs through your contract? That changes the approach completely.

If you need all tokenIDs owned by a specific address, you might need enumeration functions like tokenOfOwnerByIndex() if the contract supports ERC721Enumerable. But not all NFT contracts have this.

What exactly are you building with this transfer functionality? More details about your use case would help us give better guidance on handling tokenID discovery.