Skip to main content
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: 0xfa Introduced: Byzantium (EIP-214) STATICCALL executes code from another account with state modification restrictions enforced. Any attempt to modify state (SSTORE, CREATE, CALL with value, SELFDESTRUCT, LOG, etc.) reverts the entire call. This enables secure read-only operations and implements Solidity’s view and pure function semantics.

Specification

Stack Input:
Stack Output:
Gas Cost: 700 + cold_access + memory_expansion Operation:

Behavior

STATICCALL performs a read-only external call with state protection:
  1. Pop 6 stack arguments (no value parameter)
  2. Calculate gas cost:
    • Base: 700 gas (Tangerine Whistle+)
    • Cold access: +2,600 gas for first access (Berlin+)
    • Memory expansion for input and output regions
  3. Read calldata from memory
  4. Forward gas: Up to 63/64 of remaining gas (EIP-150)
  5. Execute in callee context with static flag:
    • msg.sender = caller address
    • msg.value = 0 (always zero!)
    • Storage = callee’s storage (READ-ONLY)
    • Code = callee’s code
    • is_static = true (inherited by child calls)
  6. Enforce read-only restrictions:
    • SSTORE reverts (storage modification)
    • CREATE/CREATE2 revert (contract creation)
    • CALL with value > 0 reverts (ETH transfer)
    • SELFDESTRUCT reverts (account deletion)
    • LOG0-LOG4 revert (event emission)
  7. Copy returndata to memory
  8. Set return_data buffer
  9. Push success flag
  10. Refund unused gas
Key characteristics:
  • No value transfer (msg.value always 0)
  • State modifications forbidden (enforced recursively)
  • Safe for untrusted code execution
  • Foundation for view/pure functions

Examples

Basic Static Call

View Function Call

Multi-token Reader

Safe Untrusted Call

Price Oracle Reader

Gas Cost

Total cost: 700 + cold_access + memory_expansion + forwarded_gas

Base Cost: 700 gas (Tangerine Whistle+)

Pre-Tangerine Whistle: STATICCALL didn’t exist (introduced Byzantium).

No Value Transfer Cost

STATICCALL never transfers value:

Cold Access: +2,600 gas (Berlin+)

EIP-2929 (Berlin+): First access to target address:
Pre-Berlin: No access list costs.

Memory Expansion

Same as CALL - charges for both input and output regions:

Gas Forwarding (EIP-150)

63/64 rule applies:

Example Calculation

Common Usage

Safe Contract Query

View Function Multicall

Contract Existence Check

Security

State Modification Prevention

STATICCALL enforces read-only semantics:
Protected operations (revert in static context):
  • SSTORE (storage write)
  • CREATE/CREATE2 (contract creation)
  • CALL with value > 0 (ETH transfer)
  • SELFDESTRUCT (account deletion)
  • LOG0-LOG4 (event emission)

Read-Only Guarantee

STATICCALL guarantees no state changes:

Gas Limit Attacks

Callee still controls gas consumption:

Returndata Bomb

Large returndata can cause OOG when copying:

Reentrancy (Still Possible!)

Read-only reentrancy is possible:
Mitigation: Checks-Effects-Interactions pattern.

Implementation

References