Overview
Opcode:0x34
Introduced: Frontier (EVM genesis)
CALLVALUE pushes the amount of wei sent with the current call onto the stack. This corresponds to msg.value in Solidity.
Specification
Stack Input:Behavior
CALLVALUE provides access to the wei amount sent with the current message call. This value is always 0 for STATICCALL and DELEGATECALL. Key characteristics:- Returns wei amount (1 ether = 10^18 wei)
- Always 0 for STATICCALL (no value transfer allowed)
- Preserved in DELEGATECALL (uses caller’s value)
- New value for each CALL
Examples
Basic Usage
Payable Function
Deposit Pattern
Gas Cost
Cost: 2 gas (GasQuickStep) Same as other environment context opcodes:- ADDRESS (0x30): 2 gas
- ORIGIN (0x32): 2 gas
- CALLER (0x33): 2 gas
Common Usage
Minimum Payment
Exact Payment
Value Forwarding
Crowdfunding
Security
Payable vs Non-Payable
Reentrancy with Value
Value Conservation
DELEGATECALL Value Preservation
Implementation
- TypeScript
Edge Cases
Zero Value
Maximum Value
Stack Overflow
References
- Yellow Paper - Section 9.3 (Execution Environment)
- EVM Codes - CALLVALUE
- Solidity Docs - msg.value
- SWC-132: Unexpected Ether balance

