Skip to content
sambachaPublic

About

Open Ethereum Virtual Machine - Knowledgebase, Documentation, etc

Topics

Resources

Stars

50 stars

Watchers

2 watching

Forks

Repository files navigation

Warning

See v2 Site

EVM opcodes vs ewasm methods

These tables compares EVM opcodes with ewasm methods and wasm instructions. The EVM defines 134 opcodes (as of the Byzantium hard fork). Of these 134 opcodes, some represent generic machine instructions (ADD, MUL, ISZERO, XOR, etc.) and the rest are Ethereum-specific operations (SLOAD, SSTORE, GASPRICE, BLOCKHASH, etc.).

When EVM bytecode is transpiled to ewasm bytecode, the Ethereum-specific opcodes translate to corresponding ewasm interface methods (Ethereum Environment Interface (EEI) methods). These interface methods are provided as host functions to the wasm VM. All other EVM opcodes are not Ethereum-specific and do not access data from the Ethereum environment, so they reduce to pure wasm instructions.

To reference EVM opcodes, try the yellow paper, the readable yellow paper, or the pyethereum implementation.

To reference ewasm interface methods, see the EEI spec.

EVM opcodes (Byzantium) with corresponding ewasm methods (Ethereum Environment Interface (EEI) Revision 4)

EVM opcode ewasm interface method
0x00: STOP finish(0, 0)
0x30: ADDRESS getAddress
0x31: BALANCE getBalance
0x32: ORIGIN getTxOrigin
0x33: CALLER getCaller
0x34: CALLVALUE getCallValue
0x35: CALLDATALOAD callDataCopy(resultOffset, dataOffset, 32)
0x36: CALLDATASIZE getCallDataSize
0x37: CALLDATACOPY callDataCopy(resultOffset, dataOffset, size)
0x38: CODESIZE getCodeSize
0x39: CODECOPY codeCopy