I extracted the contracted address from a transaction hash.Now I want know its tokenID , is there any method through web3.py that could help ,or any other way in which I can get tokenID of that contract address.

4 Answers 4


I think you've misunderstood ERC-721. An ERC-721 contract can contain multiple tokens (denoted by token id). If you want let's say the tokenURI of a particular tokenID, you can call tokenURI(tokenId) to get the URI of that particular token. That said, the contract can also contain just 1 token. So get the number of tokens it contains, in certain contracts you can check via totalSupply() function. But it's not guaranteed that all ERC-721 contracts will have totalSupply implemented.


Yes you can check if it's an ERC721 , it has nothing to do with TokenIDs though. The other answer explains why.


ERC721 contract allows to mint a token. This token would have a token id, not the contract itself.

There are several options to get token ids from ERC721 contract.

ERC721 standard allows to have Enumerable interface which gives access to token ids. Although, there is well known security attack on its concept and implementation by overusing balanceOf() call (or may be something different).

Another option is query events for this contract and search of returned results for pair user-tokenId.

Finally we can store a minted token id in the separate special storage.

I prefer the last one. It is not issue when you are developer of the contract.

  • Please note Enumerable usage not only open a security risk, but also significantly increase cost of usage which looks like a one of major issues of using blockchain technology in production.
    – Gleichmut
    Commented Dec 8, 2022 at 10:58

I basically wont to identify whether the contract is of ERC721 through its address.

Therefore I thought using token id as reference like if contract has token id it will be of ERC721.

Is there any other way that could help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.