Overview
Opcode:0x3a
Introduced: Frontier (EVM genesis)
GASPRICE pushes the gas price of the current transaction onto the stack, measured in wei per gas unit.
Specification
Stack Input:Behavior
Returns the gas price specified in the transaction. For EIP-1559 transactions, this is the effective gas price (baseFee + priorityFee). Key characteristics:- Same value throughout transaction
- In wei per gas unit
- For EIP-1559: min(baseFee + maxPriorityFeePerGas, maxFeePerGas)
- For legacy: transaction’s gasPrice field
Examples
Basic Usage
Gas Refunds
Gas Price Oracle
Gas Cost
Cost: 2 gas (GasQuickStep)Common Usage
Transaction Cost Calculation
Minimum Gas Price
Security
EIP-1559 Considerations
Post-EIP-1559, tx.gasprice is effective gas price, not maxFeePerGas:Gas Price Manipulation
Don’t use tx.gasprice for critical logic - miners can manipulate it.Implementation
- TypeScript
References
- Yellow Paper - Section 9.3
- EVM Codes - GASPRICE
- EIP-1559 - Fee market change

