1

I'm working on an ethereum explorer, I would like to know how does etherscan get the Contract source code, ABI and how they parse the transaction input hexa into contract's function?

Thanks in advance

1 Answer 1

2

Contract developers (maintainers, or basically anyone) can publish the code on https://etherscan.io/verifyContract

When you're publishing the contract on Etherscan, they ask you for the actual source code and compilation parameters such as used language (e.g. Solidity or Vyper), compiler version (e.g. 0.8.4), optimization settings and few other details.

Then Etherscan compiles the provided code with the provided params and if the (now compiled) bytecode matches the bytecode on blockchain, it publishes the source code.


ABI JSON is one of the returned values from the compilation process - along with the actual bytecode, list of opcodes, array of errors, etc.

As for the transaction input hex: They use a dictionary of function signatures that translate to the actual function definitions (including argument datatypes). You can find more info about ABI-encoding function signatures and arguments passed to functions in this other answer.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot @PeterSmith for that info, I will have to connect to etherscan API to check input data against the Contract ABI JSON.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.