1

Recently, I've seen that Etherscan is able to automatically figure out passed constructor arguments. how were they able to figure it out?

5

This was already answered in the comments to your own previous question

To summarize:

  • The transaction that created the contract is visible on Etherscan (example here)
  • The input data to that transaction, which is mostly the compiled bytecode of the contract itself, also contains the constructor parameter values in the last bytes (32 bytes per parameter)
  • Hence Etherscan is able to extract and decode the arguments passed, even without the source code, and so can you
  • Although it is not possible to know the names of the parameters without access to the source code, decompiling the bytecode can at least tell you what number and datatype/size of arguments is expected. You can use this to make sense of those 32*n bytes from the contract creation data (where n is the number of parameters)
0

The answer by Daniel Hume is wrong. Some constructors require more than 32 bytes for storage. Here is a constructor that requires 8*32 bytes: https://etherscan.io/address/0x317dc3f08f7947f363dfc7cb008048a5a5ea1840#code

So the question is still open.

  • Thank you for the correction, I've edited the answer to reflect this. – Daniel Hume Jun 3 at 21:25

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.