3

Is there any specific way of identifying ERC-721, ERC-777, & ERC-223 contract events under the EVM, specifically under the eth.getTransactionReceipt() function?

I know there's a way for ERC-20 tokens by filtering for the Transfer keccak-256 hash:

0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

A brute-force example I could use for CryptoKitties is also filtering for the 'DepositKittyAndMintToken' hash, yet obviously there are many more ERC-721 token events than just CryptoKitties:

0x999fa95b06ad12b3436bab902713e383705707923f9d7c75f5432b28a6487010

I'm running a program that runs two loops: through each transactionHash under each block, and trying to separate all ERC-20, ERC-721, ERC-777, and ERC-223 token events, yet only have it working for ERC-20's.

Any help would be greatly appreciated, thanks!

3
  • A similar question here. May 9, 2020 at 14:02
  • Oh wow, this is great, thanks! The only discrepancy is I see ERC-20 events with a receipt.topics.length == 3 not 1, while ERC-721's are receipt.topics.length == 1. I just verified on my Geth archive node for a handful of ERC-20 & CryptoKitties transactions, and this appears to be the case.
    – keennay
    May 9, 2020 at 14:13
  • Then they are not standard ERC20 event by definition. May 9, 2020 at 14:26

2 Answers 2

0

For ERC-721 and modern contract types that support ERC-165 this can be done using introspection.

The basic way to do it (implementation here shown with Node + Ethers) is:

// Use ERC-165 to check if contract is ERC-721, try/catch in case contract does not support ERC-165
const contract = new ethers.Contract(contractAddress, erc165Abi, provider);
let isErc721 = 0;
try {
    isErc721 = await contract.supportsInterface(erc721Id) ? 1 : 0;
} catch (error) {
    // Contract does not support ERC-165
}

This is excerpted from a full implementation you can study at https://github.com/fulldecent/contract-scanner/blob/main/index.mjs

Also, I have narrated and explain every line of code here if you want to dig deeper, see https://youtu.be/lukshxTYpUw and I have office course ("Community Service Hour") to answer any questions.

-1

...and just like that, came across this:

https://medium.com/axionable-ai-and-blockchain/token-ercs-in-ethereum-erc-20-erc-223-erc-777-and-erc-721-8176c0f11c18

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.