This appendix is based on the consolidation work done by the people of https://github.com/trailofbits/evm-opcodes as a reference for Ethereum VM (EVM) opcodes and instruction information licensed under the Apache License 2.0.
Opcode | Name | Description | Extra info | Gas |
---|---|---|---|---|
|
STOP |
Halts execution |
- |
0 |
|
ADD |
Addition operation |
- |
3 |
|
MUL |
Multiplication operation |
- |
5 |
|
SUB |
Subtraction operation |
- |
3 |
|
DIV |
Integer division operation |
- |
5 |
|
SDIV |
Signed integer division operation (truncated) |
- |
5 |
|
MOD |
Modulo remainder operation |
- |
5 |
|
SMOD |
Signed modulo remainder operation |
- |
5 |
|
ADDMOD |
Modulo addition operation |
- |
8 |
|
MULMOD |
Modulo multiplication operation |
- |
8 |
|
EXP |
Exponential operation |
- |
10*** |
|
SIGNEXTEND |
Extend length of two’s complement signed integer |
- |
5 |
|
Unused |
Unused |
- |
|
|
LT |
Less-than comparison |
- |
3 |
|
GT |
Greater-than comparison |
- |
3 |
|
SLT |
Signed less-than comparison |
- |
3 |
|
SGT |
Signed greater-than comparison |
- |
3 |
|
EQ |
Equality comparison |
- |
3 |
|
ISZERO |
Simple NOT operator |
- |
3 |
|
AND |
Bitwise AND operation |
- |
3 |
|
OR |
Bitwise OR operation |
- |
3 |
|
XOR |
Bitwise XOR operation |
- |
3 |
|
NOT |
Bitwise NOT operation |
- |
3 |
|
BYTE |
Retrieve single byte from word |
- |
3 |
|
Unused |
Unused |
- |
|
|
SHA3 |
Compute Keccak-256 hash |
- |
30 |
|
Unused |
Unused |
- |
|
|
ADDRESS |
Get address of currently executing account |
- |
2 |
|
BALANCE |
Get balance of the given account |
- |
400 |
|
ORIGIN |
Get execution origination address |
- |
2 |
|
CALLER |
Get caller address |
- |
2 |
|
CALLVALUE |
Get deposited value by the instruction/transaction responsible for this execution |
- |
2 |
|
CALLDATALOAD |
Get input data of current environment |
- |
3 |
|
CALLDATASIZE |
Get size of input data in current environment |
- |
2 |
|
CALLDATACOPY |
Copy input data in current environment to memory |
- |
3 |
|
CODESIZE |
Get size of code running in current environment |
- |
2 |
|
CODECOPY |
Copy code running in current environment to memory |
- |
3 |
|
GASPRICE |
Get price of gas in current environment |
- |
2 |
|
EXTCODESIZE |
Get size of an account’s code |
- |
700 |
|
EXTCODECOPY |
Copy an account’s code to memory |
- |
700 |
|
RETURNDATASIZE |
Pushes the size of the return data buffer onto the stack |
2 |
|
|
RETURNDATACOPY |
Copies data from the return data buffer to memory |
3 |
|
|
Unused |
- |
- |
|
|
BLOCKHASH |
Get the hash of one of the 256 most recent complete blocks |
- |
20 |
|
COINBASE |
Get the block’s beneficiary address |
- |
2 |
|
TIMESTAMP |
Get the block’s timestamp |
- |
2 |
|
NUMBER |
Get the block’s number |
- |
2 |
|
DIFFICULTY |
Get the block’s difficulty |
- |
2 |
|
GASLIMIT |
Get the block’s gas limit |
- |
2 |
|
Unused |
- |
- |
|
|
POP |
Remove word from stack |
- |
2 |
|
MLOAD |
Load word from memory |
- |
3 |
|
MSTORE |
Save word to memory |
- |
3* |
|
MSTORE8 |
Save byte to memory |
- |
3 |
|
SLOAD |
Load word from storage |
- |
200 |
|
SSTORE |
Save word to storage |
- |
0* |
|
JUMP |
Alter the program counter |
- |
8 |
|
JUMPI |
Conditionally alter the program counter |
- |
10 |
|
GETPC |
Get the value of the program counter prior to the increment |
- |
2 |
|
MSIZE |
Get the size of active memory in bytes |
- |
2 |
|
GAS |
Get the amount of available gas, including the corresponding reduction in the amount of available gas |
- |
2 |
|
JUMPDEST |
Mark a valid destination for jumps |
- |
1 |
|
Unused |
- |
- |
|
|
PUSH1 |
Place 1-byte item on stack |
- |
3 |
|
PUSH2 |
Place 2-byte item on stack |
- |
3 |
|
PUSH3 |
Place 3-byte item on stack |
- |
3 |
|
PUSH4 |
Place 4-byte item on stack |
- |
3 |
|
PUSH5 |
Place 5-byte item on stack |
- |
3 |
|
PUSH6 |
Place 6-byte item on stack |
- |
3 |
|
PUSH7 |
Place 7-byte item on stack |
- |
3 |
|
PUSH8 |
Place 8-byte item on stack |
- |
3 |
|
PUSH9 |
Place 9-byte item on stack |
- |
3 |
|
PUSH10 |
Place 10-byte item on stack |
- |
3 |
|
PUSH11 |
Place 11-byte item on stack |
- |
3 |
|
PUSH12 |
Place 12-byte item on stack |
- |
3 |
|
PUSH13 |
Place 13-byte item on stack |
- |
3 |
|
PUSH14 |
Place 14-byte item on stack |
- |
3 |
|
PUSH15 |
Place 15-byte item on stack |
- |
3 |
|
PUSH16 |
Place 16-byte item on stack |
- |
3 |
|
PUSH17 |
Place 17-byte item on stack |
- |
3 |
|
PUSH18 |
Place 18-byte item on stack |
- |
3 |
|
PUSH19 |
Place 19-byte item on stack |
- |
3 |
|
PUSH20 |
Place 20-byte item on stack |
- |
3 |
|
PUSH21 |
Place 21-byte item on stack |
- |
3 |
|
PUSH22 |
Place 22-byte item on stack |
- |
3 |
|
PUSH23 |
Place 23-byte item on stack |
- |
3 |
|
PUSH24 |
Place 24-byte item on stack |
- |
3 |
|
PUSH25 |
Place 25-byte item on stack |
- |
3 |
|
PUSH26 |
Place 26-byte item on stack |
- |
3 |
|
PUSH27 |
Place 27-byte item on stack |
- |
3 |
|
PUSH28 |
Place 28-byte item on stack |
- |
3 |
|
PUSH29 |
Place 29-byte item on stack |
- |
3 |
|
PUSH30 |
Place 30-byte item on stack |
- |
3 |
|
PUSH31 |
Place 31-byte item on stack |
- |
3 |
|
PUSH32 |
Place 32-byte (full word) item on stack |
- |
3 |
|
DUP1 |
Duplicate 1st stack item |
- |
3 |
|
DUP2 |
Duplicate 2nd stack item |
- |
3 |
|
DUP3 |
Duplicate 3rd stack item |
- |
3 |
|
DUP4 |
Duplicate 4th stack item |
- |
3 |
|
DUP5 |
Duplicate 5th stack item |
- |
3 |
|
DUP6 |
Duplicate 6th stack item |
- |
3 |
|
DUP7 |
Duplicate 7th stack item |
- |
3 |
|
DUP8 |
Duplicate 8th stack item |
- |
3 |
|
DUP9 |
Duplicate 9th stack item |
- |
3 |
|
DUP10 |
Duplicate 10th stack item |
- |
3 |
|
DUP11 |
Duplicate 11th stack item |
- |
3 |
|
DUP12 |
Duplicate 12th stack item |
- |
3 |
|
DUP13 |
Duplicate 13th stack item |
- |
3 |
|
DUP14 |
Duplicate 14th stack item |
- |
3 |
|
DUP15 |
Duplicate 15th stack item |
- |
3 |
|
DUP16 |
Duplicate 16th stack item |
- |
3 |
|
SWAP1 |
Exchange 1st and 2nd stack items |
- |
3 |
|
SWAP2 |
Exchange 1st and 3rd stack items |
- |
3 |
|
SWAP3 |
Exchange 1st and 4th stack items |
- |
3 |
|
SWAP4 |
Exchange 1st and 5th stack items |
- |
3 |
|
SWAP5 |
Exchange 1st and 6th stack items |
- |
3 |
|
SWAP6 |
Exchange 1st and 7th stack items |
- |
3 |
|
SWAP7 |
Exchange 1st and 8th stack items |
- |
3 |
|
SWAP8 |
Exchange 1st and 9th stack items |
- |
3 |
|
SWAP9 |
Exchange 1st and 10th stack items |
- |
3 |
|
SWAP10 |
Exchange 1st and 11th stack items |
- |
3 |
|
SWAP11 |
Exchange 1st and 12th stack items |
- |
3 |
|
SWAP12 |
Exchange 1st and 13th stack items |
- |
3 |
|
SWAP13 |
Exchange 1st and 14th stack items |
- |
3 |
|
SWAP14 |
Exchange 1st and 15th stack items |
- |
3 |
|
SWAP15 |
Exchange 1st and 16th stack items |
- |
3 |
|
SWAP16 |
Exchange 1st and 17th stack items |
- |
3 |
|
LOG0 |
Append log record with no topics |
- |
375 |
|
LOG1 |
Append log record with one topic |
- |
750 |
|
LOG2 |
Append log record with two topics |
- |
1125 |
|
LOG3 |
Append log record with three topics |
- |
1500 |
|
LOG4 |
Append log record with four topics |
- |
1875 |
|
Unused |
- |
- |
|
|
JUMPTO |
Tentative libevmasm has different numbers |
||
|
JUMPIF |
Tentative |
||
|
JUMPSUB |
Tentative |
||
|
JUMPSUBV |
Tentative |
||
|
BEGINSUB |
Tentative |
||
|
BEGINDATA |
Tentative |
||
|
RETURNSUB |
Tentative |
||
|
PUTLOCAL |
Tentative |
||
|
GETLOCA |
Tentative |
||
|
Unused |
- |
- |
|
|
SLOADBYTES |
Only referenced in pyethereum |
- |
- |
|
SSTOREBYTES |
Only referenced in pyethereum |
- |
- |
|
SSIZE |
Only referenced in pyethereum |
- |
- |
|
Unused |
- |
- |
|
|
CREATE |
Create a new account with associated code |
- |
32000 |
|
CALL |
Message-call into an account |
- |
Complicated |
|
CALLCODE |
Message-call into this account with alternative account’s code |
- |
Complicated |
|
RETURN |
Halt execution returning output data |
- |
0 |
|
DELEGATECALL |
Message-call into this account with an alternative account’s code, but persisting into this account with an alternative account’s code |
- |
Complicated |
|
CALLBLACKBOX |
- |
- |
40 |
|
Unused |
- |
- |
|
|
STATICCALL |
Similar to CALL, but does not modify state |
- |
40 |
|
CREATE2 |
Create a new account and set creation address to |
- |
|
|
TXEXECGAS |
Not in yellow paper FIXME |
- |
- |
|
REVERT |
Stop execution and revert state changes, without consuming all provided gas and providing a reason |
- |
0 |
|
INVALID |
Designated invalid instruction |
- |
0 |
|
SELFDESTRUCT |
Halt execution and register account for later deletion |
- |
5000* |