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: 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:
Stack Output:
Gas Cost: 2 (GasQuickStep)
Operation:
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
References