2

There are many tools and visualizers to use to read through a transaction, but where can I go to learn how to understand this?

Fore example, that first link has a series of opcodes (and their associated gas and depth). If I had access to the contract, would I be able to compare the opcodes to different parts of the contract? Do solidity functions match up with opcode(s)? In order to read this, must I see a group of say 5 opcodes and know "oh this is adding two numbers"?

1

The code in Ethereum is executed on the Ethereum Virtual Machine which is a stack-machine which executes instructions. A call to any contract starts with the instruction pointer at 0 meaning that the first instruction in the code placed on an address is always executed first.

A short introduction to how function calls are handled in Ethereum, on an opcode level, can be found in this answer: What is the program counter at the start of an Ethereum method execution?

It is definitely possible to learn what the different opcodes mean. It is certainly easier if you have some prior knowledge of machine code or assembly code but that is by no means a requirement.

The best source on this is to my knowledge the Ethereum Yellow Paper Appendix H which lists all the available opcodes for the Ethereum Virtual Machine.

For example the opcode ADD (0x01) (page 28 of the Yellow Paper) removes to values from the stack and adds one new value to the stack where the new value on top of the stack will be the sum of the two values removed from the stack (modulus 2^256).

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.