#[repr(u8)]pub enum Instruction {
Show 146 variants
STOP = 0,
ADD = 1,
MUL = 2,
SUB = 3,
DIV = 4,
SDIV = 5,
MOD = 6,
SMOD = 7,
ADDMOD = 8,
MULMOD = 9,
EXP = 10,
SIGNEXTEND = 11,
LT = 16,
GT = 17,
SLT = 18,
SGT = 19,
EQ = 20,
ISZERO = 21,
AND = 22,
OR = 23,
XOR = 24,
NOT = 25,
BYTE = 26,
SHL = 27,
SHR = 28,
SAR = 29,
SHA3 = 32,
ADDRESS = 48,
BALANCE = 49,
ORIGIN = 50,
CALLER = 51,
CALLVALUE = 52,
CALLDATALOAD = 53,
CALLDATASIZE = 54,
CALLDATACOPY = 55,
CODESIZE = 56,
CODECOPY = 57,
GASPRICE = 58,
EXTCODESIZE = 59,
EXTCODECOPY = 60,
RETURNDATASIZE = 61,
RETURNDATACOPY = 62,
EXTCODEHASH = 63,
BLOCKHASH = 64,
COINBASE = 65,
TIMESTAMP = 66,
NUMBER = 67,
DIFFICULTY = 68,
GASLIMIT = 69,
CHAINID = 70,
SELFBALANCE = 71,
BASEFEE = 72,
POP = 80,
MLOAD = 81,
MSTORE = 82,
MSTORE8 = 83,
SLOAD = 84,
SSTORE = 85,
JUMP = 86,
JUMPI = 87,
PC = 88,
MSIZE = 89,
GAS = 90,
JUMPDEST = 91,
BEGINSUB_TLOAD = 92,
RETURNSUB_TSTORE = 93,
JUMPSUB_MCOPY = 94,
PUSH0 = 95,
PUSH1 = 96,
PUSH2 = 97,
PUSH3 = 98,
PUSH4 = 99,
PUSH5 = 100,
PUSH6 = 101,
PUSH7 = 102,
PUSH8 = 103,
PUSH9 = 104,
PUSH10 = 105,
PUSH11 = 106,
PUSH12 = 107,
PUSH13 = 108,
PUSH14 = 109,
PUSH15 = 110,
PUSH16 = 111,
PUSH17 = 112,
PUSH18 = 113,
PUSH19 = 114,
PUSH20 = 115,
PUSH21 = 116,
PUSH22 = 117,
PUSH23 = 118,
PUSH24 = 119,
PUSH25 = 120,
PUSH26 = 121,
PUSH27 = 122,
PUSH28 = 123,
PUSH29 = 124,
PUSH30 = 125,
PUSH31 = 126,
PUSH32 = 127,
DUP1 = 128,
DUP2 = 129,
DUP3 = 130,
DUP4 = 131,
DUP5 = 132,
DUP6 = 133,
DUP7 = 134,
DUP8 = 135,
DUP9 = 136,
DUP10 = 137,
DUP11 = 138,
DUP12 = 139,
DUP13 = 140,
DUP14 = 141,
DUP15 = 142,
DUP16 = 143,
SWAP1 = 144,
SWAP2 = 145,
SWAP3 = 146,
SWAP4 = 147,
SWAP5 = 148,
SWAP6 = 149,
SWAP7 = 150,
SWAP8 = 151,
SWAP9 = 152,
SWAP10 = 153,
SWAP11 = 154,
SWAP12 = 155,
SWAP13 = 156,
SWAP14 = 157,
SWAP15 = 158,
SWAP16 = 159,
LOG0 = 160,
LOG1 = 161,
LOG2 = 162,
LOG3 = 163,
LOG4 = 164,
CREATE = 240,
CALL = 241,
CALLCODE = 242,
RETURN = 243,
DELEGATECALL = 244,
CREATE2 = 245,
STATICCALL = 250,
REVERT = 253,
SUICIDE = 255,
}
Expand description
Virtual machine bytecode instruction.
Variants§
STOP = 0
halts execution
ADD = 1
addition operation
MUL = 2
multiplication operation
SUB = 3
subtraction operation
DIV = 4
integer division operation
SDIV = 5
signed integer division operation
MOD = 6
modulo remainder operation
SMOD = 7
signed modulo remainder operation
ADDMOD = 8
unsigned modular addition
MULMOD = 9
unsigned modular multiplication
EXP = 10
exponential operation
SIGNEXTEND = 11
extend length of signed integer
LT = 16
less-than comparison
GT = 17
greater-than comparison
SLT = 18
signed less-than comparison
SGT = 19
signed greater-than comparison
EQ = 20
equality comparison
ISZERO = 21
simple not operator
AND = 22
bitwise AND operation
OR = 23
bitwise OR operation
XOR = 24
bitwise XOR operation
NOT = 25
bitwise NOT operation
BYTE = 26
retrieve single byte from word
SHL = 27
shift left operation
SHR = 28
logical shift right operation
SAR = 29
arithmetic shift right operation
SHA3 = 32
compute SHA3-256 hash
ADDRESS = 48
get address of currently executing account
BALANCE = 49
get balance of the given account
ORIGIN = 50
get execution origination address
CALLER = 51
get caller address
CALLVALUE = 52
get deposited value by the instruction/transaction responsible for this execution
CALLDATALOAD = 53
get input data of current environment
CALLDATASIZE = 54
get size of input data in current environment
CALLDATACOPY = 55
copy input data in current environment to memory
CODESIZE = 56
get size of code running in current environment
CODECOPY = 57
copy code running in current environment to memory
GASPRICE = 58
get price of gas in current environment
EXTCODESIZE = 59
get external code size (from another contract)
EXTCODECOPY = 60
copy external code (from another contract)
RETURNDATASIZE = 61
get the size of the return data buffer for the last call
RETURNDATACOPY = 62
copy return data buffer to memory
EXTCODEHASH = 63
return the keccak256 hash of contract code
BLOCKHASH = 64
get hash of most recent complete block
COINBASE = 65
get the block’s coinbase address
TIMESTAMP = 66
get the block’s timestamp
NUMBER = 67
get the block’s number
DIFFICULTY = 68
get the block’s difficulty
GASLIMIT = 69
get the block’s gas limit
CHAINID = 70
get chain ID
SELFBALANCE = 71
get balance of own account
BASEFEE = 72
base fee for EIP-1559 (EIP-3198)
POP = 80
remove item from stack
MLOAD = 81
load word from memory
MSTORE = 82
save word to memory
MSTORE8 = 83
save byte to memory
SLOAD = 84
load word from storage
SSTORE = 85
save word to storage
JUMP = 86
alter the program counter
JUMPI = 87
conditionally alter the program counter
PC = 88
get the program counter
MSIZE = 89
get the size of active memory
GAS = 90
get the amount of available gas
JUMPDEST = 91
set a potential jump destination
BEGINSUB_TLOAD = 92
Marks the entry point to a subroutine (pre cip-142). load word from transient storage (after cip-142)
RETURNSUB_TSTORE = 93
Returns from a subroutine (pre cip-142). store word from transient storage (after cip-142)
JUMPSUB_MCOPY = 94
Jumps to a defined BEGINSUB subroutine (pre cip-143). copy data from one memory range to another (after cip-143)
PUSH0 = 95
place zero item on stack (EIP-3855/CIP-119)
PUSH1 = 96
place 1 byte item on stack
PUSH2 = 97
place 2 byte item on stack
PUSH3 = 98
place 3 byte item on stack
PUSH4 = 99
place 4 byte item on stack
PUSH5 = 100
place 5 byte item on stack
PUSH6 = 101
place 6 byte item on stack
PUSH7 = 102
place 7 byte item on stack
PUSH8 = 103
place 8 byte item on stack
PUSH9 = 104
place 9 byte item on stack
PUSH10 = 105
place 10 byte item on stack
PUSH11 = 106
place 11 byte item on stack
PUSH12 = 107
place 12 byte item on stack
PUSH13 = 108
place 13 byte item on stack
PUSH14 = 109
place 14 byte item on stack
PUSH15 = 110
place 15 byte item on stack
PUSH16 = 111
place 16 byte item on stack
PUSH17 = 112
place 17 byte item on stack
PUSH18 = 113
place 18 byte item on stack
PUSH19 = 114
place 19 byte item on stack
PUSH20 = 115
place 20 byte item on stack
PUSH21 = 116
place 21 byte item on stack
PUSH22 = 117
place 22 byte item on stack
PUSH23 = 118
place 23 byte item on stack
PUSH24 = 119
place 24 byte item on stack
PUSH25 = 120
place 25 byte item on stack
PUSH26 = 121
place 26 byte item on stack
PUSH27 = 122
place 27 byte item on stack
PUSH28 = 123
place 28 byte item on stack
PUSH29 = 124
place 29 byte item on stack
PUSH30 = 125
place 30 byte item on stack
PUSH31 = 126
place 31 byte item on stack
PUSH32 = 127
place 32 byte item on stack
DUP1 = 128
copies the highest item in the stack to the top of the stack
DUP2 = 129
copies the second highest item in the stack to the top of the stack
DUP3 = 130
copies the third highest item in the stack to the top of the stack
DUP4 = 131
copies the 4th highest item in the stack to the top of the stack
DUP5 = 132
copies the 5th highest item in the stack to the top of the stack
DUP6 = 133
copies the 6th highest item in the stack to the top of the stack
DUP7 = 134
copies the 7th highest item in the stack to the top of the stack
DUP8 = 135
copies the 8th highest item in the stack to the top of the stack
DUP9 = 136
copies the 9th highest item in the stack to the top of the stack
DUP10 = 137
copies the 10th highest item in the stack to the top of the stack
DUP11 = 138
copies the 11th highest item in the stack to the top of the stack
DUP12 = 139
copies the 12th highest item in the stack to the top of the stack
DUP13 = 140
copies the 13th highest item in the stack to the top of the stack
DUP14 = 141
copies the 14th highest item in the stack to the top of the stack
DUP15 = 142
copies the 15th highest item in the stack to the top of the stack
DUP16 = 143
copies the 16th highest item in the stack to the top of the stack
SWAP1 = 144
swaps the highest and second highest value on the stack
SWAP2 = 145
swaps the highest and third highest value on the stack
SWAP3 = 146
swaps the highest and 4th highest value on the stack
SWAP4 = 147
swaps the highest and 5th highest value on the stack
SWAP5 = 148
swaps the highest and 6th highest value on the stack
SWAP6 = 149
swaps the highest and 7th highest value on the stack
SWAP7 = 150
swaps the highest and 8th highest value on the stack
SWAP8 = 151
swaps the highest and 9th highest value on the stack
SWAP9 = 152
swaps the highest and 10th highest value on the stack
SWAP10 = 153
swaps the highest and 11th highest value on the stack
SWAP11 = 154
swaps the highest and 12th highest value on the stack
SWAP12 = 155
swaps the highest and 13th highest value on the stack
SWAP13 = 156
swaps the highest and 14th highest value on the stack
SWAP14 = 157
swaps the highest and 15th highest value on the stack
SWAP15 = 158
swaps the highest and 16th highest value on the stack
SWAP16 = 159
swaps the highest and 17th highest value on the stack
LOG0 = 160
Makes a log entry, no topics.
LOG1 = 161
Makes a log entry, 1 topic.
LOG2 = 162
Makes a log entry, 2 topics.
LOG3 = 163
Makes a log entry, 3 topics.
LOG4 = 164
Makes a log entry, 4 topics.
CREATE = 240
create a new account with associated code
CALL = 241
message-call into an account
CALLCODE = 242
message-call with another account’s code only
RETURN = 243
halt execution returning output data
DELEGATECALL = 244
like CALLCODE but keeps caller’s value and sender
CREATE2 = 245
create a new account and set creation address to sha3(sender + sha3(init code)) % 2**160
STATICCALL = 250
like CALL but it does not take value, nor modify the state
REVERT = 253
stop execution and revert state changes. Return output data.
SUICIDE = 255
halt execution and register account for later deletion
Implementations§
source§impl Instruction
impl Instruction
source§impl Instruction
impl Instruction
pub fn from_u8_versioned(value: u8, spec: &Spec) -> Option<Self>
pub fn u8(self) -> u8
sourcepub fn push_bytes(&self) -> Option<usize>
pub fn push_bytes(&self) -> Option<usize>
Returns number of bytes to read for PUSHN
instruction
PUSH1 -> 1
sourcepub fn dup_position(&self) -> Option<usize>
pub fn dup_position(&self) -> Option<usize>
Returns stack position of item to duplicate DUP1 -> 0
sourcepub fn swap_position(&self) -> Option<usize>
pub fn swap_position(&self) -> Option<usize>
Returns stack position of item to SWAP top with SWAP1 -> 1
sourcepub fn log_topics(&self) -> Option<usize>
pub fn log_topics(&self) -> Option<usize>
Returns number of topics to take from stack LOG0 -> 0
sourcepub fn info<const CANCUN: bool>(&self) -> &InstructionInfo
pub fn info<const CANCUN: bool>(&self) -> &InstructionInfo
Returns the instruction info.
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl Hash for Instruction
impl Hash for Instruction
source§impl Ord for Instruction
impl Ord for Instruction
source§fn cmp(&self, other: &Instruction) -> Ordering
fn cmp(&self, other: &Instruction) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for Instruction
impl PartialEq for Instruction
source§fn eq(&self, other: &Instruction) -> bool
fn eq(&self, other: &Instruction) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for Instruction
impl PartialOrd for Instruction
source§fn partial_cmp(&self, other: &Instruction) -> Option<Ordering>
fn partial_cmp(&self, other: &Instruction) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more