pub enum Opcode {
Show 155 variants
Stop,
Add,
Mul,
Sub,
Div,
Sdiv,
Mod,
Smod,
Addmod,
Mulmod,
Exp,
Signextend,
Lt,
Gt,
Slt,
Sgt,
Eq,
Iszero,
And,
Or,
Xor,
Not,
Byte,
Shl,
Shr,
Sar,
Keccak256,
Address,
Balance,
Origin,
Caller,
Callvalue,
Calldataload,
Calldatasize,
Calldatacopy,
Codesize,
Codecopy,
Gasprice,
Extcodesize,
Extcodecopy,
Returndatasize,
Returndatacopy,
Blockhash,
Coinbase,
Timestamp,
Number,
Difficulty,
Prevrandao,
Gaslimit,
Chainid,
Clz,
Selfbalance,
Basefee,
Blobhash,
Blobbasefee,
Slotnum,
Pop,
Mload,
Mstore,
Mstore8,
Sload,
Sstore,
Jump,
Jumpi,
Pc,
Msize,
Gas,
Jumpdest,
Push0,
Push1,
Push2,
Push3,
Push4,
Push5,
Push6,
Push7,
Push8,
Push9,
Push10,
Push11,
Push12,
Push13,
Push14,
Push15,
Push16,
Push17,
Push18,
Push19,
Push20,
Push21,
Push22,
Push23,
Push24,
Push25,
Push26,
Push27,
Push28,
Push29,
Push30,
Push31,
Push32,
Dup1,
Dup2,
Dup3,
Dup4,
Dup5,
Dup6,
Dup7,
Dup8,
Dup9,
Dup10,
Dup11,
Dup12,
Dup13,
Dup14,
Dup15,
Dup16,
Dupn,
Swap1,
Swap2,
Swap3,
Swap4,
Swap5,
Swap6,
Swap7,
Swap8,
Swap9,
Swap10,
Swap11,
Swap12,
Swap13,
Swap14,
Swap15,
Swap16,
Swapn,
Exchange,
Log0,
Log1,
Log2,
Log3,
Log4,
Tload,
Tstore,
Mcopy,
Create,
Call,
Callcode,
Return,
Delegatecall,
Create2,
Staticcall,
Revert,
Invalid,
Selfdestruct,
Extcodehash,
}Expand description
EVM Opcodes References https://evm.codes and https://github.com/ethereum/execution-specs/blob/master/lists/evm/proposed-opcodes.md
Variants§
Stop
Halts execution.
Add
Addition operation
Mul
Multiplication Operation
Sub
Subtraction Operation
Div
Integer Division Operation
Sdiv
Signed Integer Division Operation
Mod
Modulo Remainder Operation
Smod
Signed Modulo Remainder Operation
Addmod
Modulo Addition Operation
Mulmod
Modulo Multiplication Operation
Exp
Exponential Operation
Signextend
Extend Length of Two’s Complement Signed Integer
Lt
Less-than Comparison
Gt
Greater-than Comparison
Slt
Signed Less-than Comparison
Sgt
Signed Greater-than Comparison
Eq
Equality Comparison
Iszero
Not Operation
And
Bitwise AND Operation
Or
Bitwise OR Operation
Xor
Bitwise XOR Operation
Not
Bitwise NOT Operation
Byte
Retrieve Single Byte from Word
Shl
Left Shift Operation
Shr
Right Shift Operation
Sar
Arithmetic Shift Right Operation
Keccak256
Compute the Keccak-256 hash of a 32-byte word
Address
Address of currently executing account
Balance
Balance of a given account
Origin
Address of execution origination
Caller
Address of the caller
Callvalue
Value of the call
Calldataload
Loads Calldata
Calldatasize
Size of the Calldata
Calldatacopy
Copies the Calldata to Memory
Codesize
Size of the Executing Code
Codecopy
Copies Executing Code to Memory
Gasprice
Current Price of Gas
Extcodesize
Size of an Account’s Code
Extcodecopy
Copies an Account’s Code to Memory
Returndatasize
Size of Output Data from Previous Call
Returndatacopy
Copies Output Data from Previous Call to Memory
Blockhash
Hash of a Block from the most recent 256 blocks
Coinbase
The Current Blocks Beneficiary Address
Timestamp
The Current Blocks Timestamp
Number
The Current Blocks Number
Difficulty
The Current Blocks Difficulty
Prevrandao
Pseudorandomness from the Beacon Chain
Gaslimit
The Current Blocks Gas Limit
Chainid
The Chain ID
Clz
Count Leading Zeros - Returns the number of zeros preceding the most significant one bit
Selfbalance
Balance of the Currently Executing Account
Basefee
Base Fee
Blobhash
Versioned hashes of blobs associated with the transaction.
Blobbasefee
Blob base fee of the current block.
Slotnum
Beacon chain slot number of the current block
Pop
Removes an Item from the Stack
Mload
Loads a word from Memory
Mstore
Stores a word in Memory
Mstore8
Stores a byte in Memory
Sload
Load a word from Storage
Sstore
Store a word in Storage
Jump
Alter the Program Counter
Jumpi
Conditionally Alter the Program Counter
Pc
Value of the Program Counter Before the Current Instruction
Msize
Size of Active Memory in Bytes
Gas
Amount of available gas including the cost of the current instruction
Jumpdest
Marks a valid destination for jumps
Push0
Places a zero on top of the stack
Push1
Places 1 byte item on top of the stack
Push2
Places 2 byte item on top of the stack
Push3
Places 3 byte item on top of the stack
Push4
Places 4 byte item on top of the stack
Push5
Places 5 byte item on top of the stack
Push6
Places 6 byte item on top of the stack
Push7
Places 7 byte item on top of the stack
Push8
Places 8 byte item on top of the stack
Push9
Places 9 byte item on top of the stack
Push10
Places 10 byte item on top of the stack
Push11
Places 11 byte item on top of the stack
Push12
Places 12 byte item on top of the stack
Push13
Places 13 byte item on top of the stack
Push14
Places 14 byte item on top of the stack
Push15
Places 15 byte item on top of the stack
Push16
Places 16 byte item on top of the stack
Push17
Places 17 byte item on top of the stack
Push18
Places 18 byte item on top of the stack
Push19
Places 19 byte item on top of the stack
Push20
Places 20 byte item on top of the stack
Push21
Places 21 byte item on top of the stack
Push22
Places 22 byte item on top of the stack
Push23
Places 23 byte item on top of the stack
Push24
Places 24 byte item on top of the stack
Push25
Places 25 byte item on top of the stack
Push26
Places 26 byte item on top of the stack
Push27
Places 27 byte item on top of the stack
Push28
Places 28 byte item on top of the stack
Push29
Places 29 byte item on top of the stack
Push30
Places 30 byte item on top of the stack
Push31
Places 31 byte item on top of the stack
Push32
Places 32 byte item on top of the stack
Dup1
Duplicates the first stack item
Dup2
Duplicates the 2nd stack item
Dup3
Duplicates the 3rd stack item
Dup4
Duplicates the 4th stack item
Dup5
Duplicates the 5th stack item
Dup6
Duplicates the 6th stack item
Dup7
Duplicates the 7th stack item
Dup8
Duplicates the 8th stack item
Dup9
Duplicates the 9th stack item
Dup10
Duplicates the 10th stack item
Dup11
Duplicates the 11th stack item
Dup12
Duplicates the 12th stack item
Dup13
Duplicates the 13th stack item
Dup14
Duplicates the 14th stack item
Dup15
Duplicates the 15th stack item
Dup16
Duplicates the 16th stack item
Dupn
Duplicate the Nth stack item (17 <= N <= 235), with N given by an immediate byte
Swap1
Exchange the top two stack items
Swap2
Exchange the first and third stack items
Swap3
Exchange the first and fourth stack items
Swap4
Exchange the first and fifth stack items
Swap5
Exchange the first and sixth stack items
Swap6
Exchange the first and seventh stack items
Swap7
Exchange the first and eighth stack items
Swap8
Exchange the first and ninth stack items
Swap9
Exchange the first and tenth stack items
Swap10
Exchange the first and eleventh stack items
Swap11
Exchange the first and twelfth stack items
Swap12
Exchange the first and thirteenth stack items
Swap13
Exchange the first and fourteenth stack items
Swap14
Exchange the first and fifteenth stack items
Swap15
Exchange the first and sixteenth stack items
Swap16
Exchange the first and seventeenth stack items
Swapn
Exchange the first and (N+1)th stack items (17 <= N <= 235), with N given by an immediate byte
Exchange
Exchange the (N+1)th and (M+1)th stack items, with N and M given by an immediate byte
Log0
Append Log Record with no Topics
Log1
Append Log Record with 1 Topic
Log2
Append Log Record with 2 Topics
Log3
Append Log Record with 3 Topics
Log4
Append Log Record with 4 Topics
Tload
Transaction-persistent, but storage-ephemeral variable load
Tstore
Transaction-persistent, but storage-ephemeral variable store
Mcopy
Copies an area of memory from src to dst. Areas can overlap.
Create
Create a new account with associated code
Call
Message-call into an account
Callcode
Message-call into this account with an alternative accounts code
Return
Halt execution, returning output data
Delegatecall
Message-call into this account with an alternative accounts code, persisting the sender and value
Create2
Create a new account with associated code
Staticcall
Static Message-call into an account
Revert
Halt execution, reverting state changes, but returning data and remaining gas
Invalid
Invalid Instruction
Selfdestruct
Halt Execution and Register Account for later deletion
Extcodehash
Get hash of an account’s code
Implementations§
Source§impl Opcode
impl Opcode
Sourcepub fn is_value_push(&self) -> bool
pub fn is_value_push(&self) -> bool
Returns true if the current opcode is a push opcode that takes a literal value
Sourcepub fn prefix_push_literal(&self, literal: &str) -> String
pub fn prefix_push_literal(&self, literal: &str) -> String
Prefixes the literal if necessary
Sourcepub fn push_size(&self) -> Option<usize>
pub fn push_size(&self) -> Option<usize>
Number of value bytes following a PUSH1..PUSH32 opcode, or None for any other opcode
Sourcepub fn stack_immediate_operands(&self) -> usize
pub fn stack_immediate_operands(&self) -> usize
Number of stack-position operands an opcode encodes in its immediate byte (EIP-8024)
dupn <n> and swapn <n> take one operand, exchange <n> <m> takes two. Every other
opcode returns 0.
Sourcepub fn has_stack_immediate(&self) -> bool
pub fn has_stack_immediate(&self) -> bool
Returns true if the opcode is followed by a one-byte stack immediate (EIP-8024)
Sourcepub fn encode_stack_immediate(&self, operands: &[usize]) -> Option<u8>
pub fn encode_stack_immediate(&self, operands: &[usize]) -> Option<u8>
Encodes the stack operands of a DUPN, SWAPN or EXCHANGE into its immediate byte
Operands use the same numbering as the EIP: dupn 17 behaves like a dup17, swapn 17
like a swap17, and exchange n m swaps the (n+1)th and (m+1)th stack items.
Returns None if the operands cannot be represented. The encoding never produces a byte
that would be read as JUMPDEST or PUSH1..PUSH32, so emitted code keeps its jump targets.
Sourcepub fn encode_immediate(&self, values: &[U256]) -> Result<String, String>
pub fn encode_immediate(&self, values: &[U256]) -> Result<String, String>
Encodes the immediate data that follows the opcode from its resolved operand values
PUSH1..PUSH32 take one value that must fit the push width; DUPN, SWAPN and EXCHANGE take
stack positions as described in Opcode::encode_stack_immediate. Returns the immediate
as a hex string, or a description of why the values cannot be encoded.
Sourcepub fn stack_immediate_hint(&self) -> String
pub fn stack_immediate_hint(&self) -> String
Describes the valid operand range of a stack-immediate opcode, for error messages
Sourcepub fn push_overflows(&self, literal: &str) -> bool
pub fn push_overflows(&self, literal: &str) -> bool
Checks if the value overflows the given push opcode
Sourcepub fn requires_evm_version(&self) -> Option<SupportedEVMVersions>
pub fn requires_evm_version(&self) -> Option<SupportedEVMVersions>
Returns the minimum EVM version required for this opcode Returns None for opcodes that have been available since the beginning
Trait Implementations§
impl Copy for Opcode
impl Eq for Opcode
Source§impl Ord for Opcode
impl Ord for Opcode
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Opcode
impl PartialOrd for Opcode
impl StructuralPartialEq for Opcode
Auto Trait Implementations§
impl Freeze for Opcode
impl RefUnwindSafe for Opcode
impl Send for Opcode
impl Sync for Opcode
impl Unpin for Opcode
impl UnsafeUnpin for Opcode
impl UnwindSafe for Opcode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
Stop: 0 bytesAdd: 0 bytesMul: 0 bytesSub: 0 bytesDiv: 0 bytesSdiv: 0 bytesMod: 0 bytesSmod: 0 bytesAddmod: 0 bytesMulmod: 0 bytesExp: 0 bytesSignextend: 0 bytesLt: 0 bytesGt: 0 bytesSlt: 0 bytesSgt: 0 bytesEq: 0 bytesIszero: 0 bytesAnd: 0 bytesOr: 0 bytesXor: 0 bytesNot: 0 bytesByte: 0 bytesShl: 0 bytesShr: 0 bytesSar: 0 bytesKeccak256: 0 bytesAddress: 0 bytesBalance: 0 bytesOrigin: 0 bytesCaller: 0 bytesCallvalue: 0 bytesCalldataload: 0 bytesCalldatasize: 0 bytesCalldatacopy: 0 bytesCodesize: 0 bytesCodecopy: 0 bytesGasprice: 0 bytesExtcodesize: 0 bytesExtcodecopy: 0 bytesReturndatasize: 0 bytesReturndatacopy: 0 bytesBlockhash: 0 bytesCoinbase: 0 bytesTimestamp: 0 bytesNumber: 0 bytesDifficulty: 0 bytesPrevrandao: 0 bytesGaslimit: 0 bytesChainid: 0 bytesClz: 0 bytesSelfbalance: 0 bytesBasefee: 0 bytesBlobhash: 0 bytesBlobbasefee: 0 bytesSlotnum: 0 bytesPop: 0 bytesMload: 0 bytesMstore: 0 bytesMstore8: 0 bytesSload: 0 bytesSstore: 0 bytesJump: 0 bytesJumpi: 0 bytesPc: 0 bytesMsize: 0 bytesGas: 0 bytesJumpdest: 0 bytesPush0: 0 bytesPush1: 0 bytesPush2: 0 bytesPush3: 0 bytesPush4: 0 bytesPush5: 0 bytesPush6: 0 bytesPush7: 0 bytesPush8: 0 bytesPush9: 0 bytesPush10: 0 bytesPush11: 0 bytesPush12: 0 bytesPush13: 0 bytesPush14: 0 bytesPush15: 0 bytesPush16: 0 bytesPush17: 0 bytesPush18: 0 bytesPush19: 0 bytesPush20: 0 bytesPush21: 0 bytesPush22: 0 bytesPush23: 0 bytesPush24: 0 bytesPush25: 0 bytesPush26: 0 bytesPush27: 0 bytesPush28: 0 bytesPush29: 0 bytesPush30: 0 bytesPush31: 0 bytesPush32: 0 bytesDup1: 0 bytesDup2: 0 bytesDup3: 0 bytesDup4: 0 bytesDup5: 0 bytesDup6: 0 bytesDup7: 0 bytesDup8: 0 bytesDup9: 0 bytesDup10: 0 bytesDup11: 0 bytesDup12: 0 bytesDup13: 0 bytesDup14: 0 bytesDup15: 0 bytesDup16: 0 bytesDupn: 0 bytesSwap1: 0 bytesSwap2: 0 bytesSwap3: 0 bytesSwap4: 0 bytesSwap5: 0 bytesSwap6: 0 bytesSwap7: 0 bytesSwap8: 0 bytesSwap9: 0 bytesSwap10: 0 bytesSwap11: 0 bytesSwap12: 0 bytesSwap13: 0 bytesSwap14: 0 bytesSwap15: 0 bytesSwap16: 0 bytesSwapn: 0 bytesExchange: 0 bytesLog0: 0 bytesLog1: 0 bytesLog2: 0 bytesLog3: 0 bytesLog4: 0 bytesTload: 0 bytesTstore: 0 bytesMcopy: 0 bytesCreate: 0 bytesCall: 0 bytesCallcode: 0 bytesReturn: 0 bytesDelegatecall: 0 bytesCreate2: 0 bytesStaticcall: 0 bytesRevert: 0 bytesInvalid: 0 bytesSelfdestruct: 0 bytesExtcodehash: 0 bytes