[Solidity] NFT contract check

in sct •  2 years ago 

Let's look at how to check whether the contract is an NFT contract on the Ethereum mainnet (or EVM chains).

The ERC-721 standard is intended to be implemented by implementing the EIP-165 interface.
And EIP-165 has a supports Interface function, and if you enter 0x80ac58cd, which is the NFT interface ID, and return true, you can confirm that it is an NFT contract.

C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iQBtxTY6amMSNFPFYo1qmAbTDiSFuji9tPJqZY2B36zWYrse2fdXewN8UHjeUVatE1og54HvCPx.png

As shown in the image above, the ERC-721 Contract will have supportsInterface function, and returns True when interfaceIddp 0x80ac58cd is entered.

When I call it from the famous BAYC Contract, it returns true as expected..!!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!