1

I am new to solidity and exploring some smart contracts. I have decompiled some on ethervm.io and they have "public and internal methods". The internal methods I see in the decompiled code as they are just functions...

I guess the public methods are somehow too, for example this hexadecimal number 0x83197ef0 corresponds to the destroy() function.. Some of these hexadecimal numbers are already mapped, most are not..

My question now is: How do I view the corresponding code of these hexadecimal numbers?

I have tried etherscan, google search and searched for public methods in solidity but couldn't find anything...

I hope someone can enlighten me or just send me a link since this should be a trivial question... Thank you so much in advance!

1 Answer 1

2

If you are only talking about the function signature part, then you can use something like https://www.4byte.directory/ to see if it has known functions for the hex value.

To generate this hex value the function signature is hashed and the resulting hash truncated. There is no way to reverse this process and therefore there is no direct way to get the original signature from the hex value.

For example if you take your destroy() signature and hash it with keccak256 (https://emn178.github.io/online-tools/keccak_256.html), you'll get 83197ef0f31073e7764b516e14f0abf207840079a6cdc8110dfcf177d053da62. The first 8 characters from that are what is used in the bytecode.

3
  • Thanks for the fast answer! But how does the EVM then know what to do? In my case i have a variable var var0 = msg.data[0x00:0x20] and then it checks if var0 == 0x1c45a491 ... There should be a way to find out what happens since the EVM also knows what to do?
    – Tom
    Nov 4, 2022 at 9:34
  • Calling the function simply sends a payload which starts with 0x83197ef0, the bytecode also has a start memory section for 0x83197ef0 and the EVM knows to direct calls with that payload to that function. Nov 4, 2022 at 9:54
  • So much to learn.. thanks a lot Lauri!
    – Tom
    Nov 4, 2022 at 10:23

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.