1

Etherscan can shows the internal transactions of each company's proprietary contracts, such as OpenSea's Seaport, for example "OrderFulFilled" event.

How do they achieve this?

If each contract follow some standard, I can understand. But seaport does not follow a standard, does it?

Or does Etherscan hardcode famous contracts?

1
  • Etherscan is a closed source block explorer. In the past they added more details for certain type of contract that are "popular". If the smart contracts source code is available they could add more details since it is good and their users will spend more time in the pages. Also it could be a service they provide, similar to advertisement.
    – Ismael
    Dec 13, 2022 at 21:14

2 Answers 2

1

Disclaimer: I don't know how etherscan does this and I don't know any correct/standard way to decode contract transactions/functions. I am also in search of the right answer here. But here's my insight.

There is the option on etherscan for contract developers to upload and verify the contract code, which in turn discloses the details of the contract such as the function signatures and event names which then presumably can be utilised by etherscan to decode the transaction details.

For example the seaport contract has its contract source code verified on etherscan: https://etherscan.io/address/0x00000000006c3852cbef3e08e8df289169ede581#code

With this said, this may not be the (only) way etherscan handles contract transactions. There are a lot of contracts without the source code, and etherscan decodes the details just fine.

One way to decode contract transactions without the source code is to compare the event logs with known events. For example, standard ERC20 transfers emit events with the same topic which is a hash of the event name. For example in this Coinbase transaction that makes multiple token transfers: https://etherscan.io/tx/0x022f2d974fc2ae9652edb846c14474be6baca76dfe2c6cb5fd1af425c7c976f7, event logs are all the same ERC20 transfer topic, despite they're from an unknown contract.

Again, there are contract transactions without clear explanatory data, and etherscan processes them just fine. Regarding internal transactions, there is another answer here that suggests etherscan run modified evm nodes themselves to record the transfers.

1

Etherscan has a db that ties the 4 byte encoded signature of the function name and params. They get the function name from verified contracts, but there are directories with this information such as https://www.4byte.directory/.

Note that the first contract to be verified has their function name as the 4byte, and there can be signature collisions.

Even if a contract isn't verified, they pull the name of a previously named contract.

Your Answer

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

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