Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

StaticCall

1 min read
Pronunciation
[stat-ik kawl]
Analogy
Imagine calling a library's information desk (the target contract) but only allowing them to *read* information from their books and tell you the answer. They are explicitly forbidden from writing anything new in the books, changing records, or making any modifications (state changes). `StaticCall` is a 'read-only' inquiry.
Definition
A type of message call in the Ethereum Virtual Machine (EVM) introduced in EIP-214. A `StaticCall` allows a contract to call another contract but explicitly disallows the called contract (and any contracts it calls further down the chain) from making any state changes.
Key Points Intro
`StaticCall` ensures that an external call cannot modify the blockchain state, enhancing security for read-only operations.
Key Points

A variant of the `CALL` opcode that restricts the called execution context to be read-only.

Any opcode that attempts to modify state (e.g., `SSTORE`, `CREATE`, `SELFDESTRUCT`, `LOG`, sending Ether) will cause the execution to revert if called within a `staticcall` context.

Useful for safely calling untrusted contracts to retrieve data without risking unintended state changes.

Functions marked as `view` or `pure` in Solidity use `staticcall` when calling other contracts.

Example
A smart contract wanting to check the balance of an ERC-20 token held by another address would use `staticcall` to invoke the token's `balanceOf` function. This ensures that calling `balanceOf` (which should be read-only) cannot accidentally trigger some hidden state change in the token contract.
Technical Deep Dive
The `STATICCALL` opcode (0xFA) was introduced to provide a guarantee that a call will not alter the blockchain state. It functions similarly to `CALL` but sets a 'static' flag in the execution environment. If any state-modifying opcode is encountered while this flag is set, the execution frame immediately reverts. This is particularly useful when interacting with potentially untrusted contracts for data retrieval, as it prevents reentrancy attacks that rely on state changes during the external call.

StaticCall - Related Articles

No related articles for this term.