I am making some erc721 transactions. I can retrieve those transactions using the etherscan api like this



This is a cryptokitties transaction. However, how do I distinguish this from a erc20 transaction. I checked their other apis https://etherscan.io/apis#contracts

but, none of them seem to explicitly state the type of contract/transaction.


That link is broken, but I'll give it a whirl.

The problem

We would like to use the Etherscan Developer API to review transactions against a given contract address and find out:

  1. Does this contract implement ERC-721?
  2. What is the list of token transfers on this contract or other useful info.

There is a lot you can do with the Etherscan Developer API. For example, here's one URL that pulls data from Ethereum Mainnet -> Etherscan -> JSON parser -> Shields.io and renders it as an image to calculate the number of Su Squares remaining for sale:

enter image description here

Source: https://img.shields.io/badge/dynamic/json.svg?label=Su+Squares+available&url=https%3A%2F%2Fapi.etherscan.io%2Fapi%3Fmodule%3Daccount%26action%3Dtokenbalance%26contractaddress%3D0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F%26address%3D0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F%26tag%3Dlatest%26apikey%3DYourApiKeyToken&query=%24.result


First, the source documentation is at https://etherscan.io/apis

It is not possible to determine which contracts support ERC-721. Source: The ERC-721 Validator. So we are going to have to use some approximation.

Here is a some ERC-721 contract, I won't tell you which one: 0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F.

We can use a special query against Etherscan to guess if it is ERC-721 compliant. This will check the original contract creation code (limiting the page and offset parameters).


Just load that file and grep that code for 42842e0e, the function signature for safeTransferFrom(address,address,uint256) and boom you found it! This makes me pretty confident because I don't expect non-721 contracts to implement that method. This approach is not fail-safe, because there are function signature collisions (expect to try 500k attempts* to collide with that one), because contracts can lie, and because a contract can use a proxy to another backing implementation.

Likewise, you can query more transactions and filter on input begins with 42842e0e to find transfers. This is still a big approximation because those transfers might fail and also because there are many ways (including internal transactions) to transfer rather than using the 42842e0e function.


This is a fun tool to test and have fun with, but for actual analysis you will want to use a real tool.

  • 2^32 byte combinations * 0.5 collision luck factor / ~5000 bytes per contract initialization

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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