Overview
Opcode:0x32
Introduced: Frontier (EVM genesis)
ORIGIN pushes the address of the account that originated the transaction (tx.origin) onto the stack. This address never changes throughout the entire call chain, unlike CALLER which changes with each call.
Specification
Stack Input:Behavior
ORIGIN provides the address of the externally owned account (EOA) that signed and initiated the transaction. This value remains constant throughout the entire execution, regardless of how many contract calls are made. Key characteristics:- Always an EOA (never a contract address)
- Immutable throughout transaction execution
- Same value in all contracts called during transaction
- Cannot be a contract (contracts cannot initiate transactions)
Examples
Basic Usage
Call Chain Comparison
Gas Cost
Cost: 2 gas (GasQuickStep) ORIGIN shares the lowest gas cost tier with other environment access opcodes:- ADDRESS (0x30)
- CALLER (0x33)
- CALLVALUE (0x34)
- CALLDATASIZE (0x36)
- CODESIZE (0x38)
- GASPRICE (0x3a)
- RETURNDATASIZE (0x3d)
Common Usage
Logging Transaction Source
Gas Refunds
Security
CRITICAL: Never Use for Authorization
VULNERABLE pattern:tx.origin vs msg.sender
Critical distinction:| Property | tx.origin | msg.sender |
|---|---|---|
| Value | Original EOA | Immediate caller |
| Changes in call chain | No | Yes |
| Can be contract | Never | Yes |
| Safe for auth | NO | YES |
| Opcode | ORIGIN (0x32) | CALLER (0x33) |
Phishing Attack Vector
Limited Valid Use Cases
Valid (but rare) use case - gas payment:Implementation
- TypeScript
Edge Cases
Stack Overflow
Out of Gas
Zero Address Origin
Best Practices
❌ DON’T: Use for authorization
✅ DO: Use msg.sender for authorization
❌ DON’T: Trust tx.origin in access control
✅ DO: Use for logging/analytics only
⚠️ CAUTION: Meta-transactions
References
- Yellow Paper - Section 9.3 (Execution Environment)
- EVM Codes - ORIGIN
- SWC-115: Authorization through tx.origin
- Solidity Docs - tx.origin
- Consensys Best Practices - Avoid tx.origin

