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
Opcode:0x63Introduced: Frontier (EVM genesis)PUSH4 pushes a 4-byte immediate value from the bytecode onto the stack. The 4 bytes immediately following the opcode are read and zero-padded to 256 bits.
value = read_bytes(pc + 1, 4) // Big-endianstack.push(value)pc += 5
Behavior
PUSH4 reads 4 bytes from bytecode starting at position pc + 1, interprets them as a big-endian unsigned integer, and pushes the result onto the stack.Key characteristics:
Reads exactly 4 bytes following opcode
Big-endian byte order (most significant byte first)
contract Example { // Function selectors use PUSH4 function transfer() public { // PUSH4 0xa9059cbb (4-byte selector) }}
Assembly Usage
assembly { // Push 4-byte value push4 0xffffffff // Example: function selector}
Gas Cost
Cost: 3 gas (GasFastestStep)All PUSH1-32 instructions cost the same despite different data sizes. Bytecode size impact:
PUSH4: 5 bytes (1 opcode + 4 data)
PUSH32: 33 bytes (1 opcode + 32 data)
Comparison:
Opcode
Gas
Bytes
Use Case
PUSH0
2
1
Zero constant (Shanghai+)
PUSH1
3
2
Small numbers (0-255)
PUSH4
3
5
Function selectors
Common Usage
Function Selectors
// Function selector is first 4 bytes of keccak256("transfer(address,uint256)")function checkSelector() public pure { assembly { let selector := shr(224, calldataload(0)) push4 0xa9059cbb // transfer selector eq // Compare }}