EVM opcodes for accessing execution environment information
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
Overview
Context instructions provide access to information about the current execution environment, including addresses, call data, gas prices, and external account state. These opcodes (0x30-0x3f) form the foundation for contracts to understand their execution context and interact with the broader blockchain state.
Instruction Categories
Environment Context (0x30-0x34)
Basic execution environment information:
ADDRESS (0x30) - Get currently executing account address
BALANCE (0x31) - Get balance of an account
ORIGIN (0x32) - Get transaction origination address
CALLER (0x33) - Get immediate caller address
CALLVALUE (0x34) - Get deposited value in current call
Call Data Access (0x35-0x37)
Reading input data passed to the contract:
CALLDATALOAD (0x35) - Load 32 bytes from calldata
CALLDATASIZE (0x36) - Get size of calldata
CALLDATACOPY (0x37) - Copy calldata to memory
Code Introspection (0x38-0x39)
Accessing the currently executing code:
CODESIZE (0x38) - Get size of executing code
CODECOPY (0x39) - Copy executing code to memory
Transaction Context (0x3a)
Transaction-level information:
GASPRICE (0x3a) - Get transaction gas price
External Account Access (0x3b-0x3f)
Querying other accounts on the blockchain:
EXTCODESIZE (0x3b) - Get size of external account’s code
EXTCODECOPY (0x3c) - Copy external account’s code to memory
RETURNDATASIZE (0x3d) - Get size of return data from last call
RETURNDATACOPY (0x3e) - Copy return data to memory
EXTCODEHASH (0x3f) - Get keccak256 hash of external account’s code
Gas Costs
Context instructions have varying gas costs based on their complexity and hardfork:Simple Environment Access (2 gas):