What is checks-effects-interactions in smart contracts?
Checks-effects-interactions is an ordering rule for Solidity functions: run the checks first, update contract storage second, and call other contracts last. If an external call comes back into the contract, it finds the state already final, so the classic reentrancy bug has nothing left to exploit.
What goes in each step?
| Step | What it covers | Example |
|---|---|---|
| Checks | Who is calling, argument ranges, amounts owed | require(owed[msg.sender] > 0) |
| Effects | Writes to storage in this contract | owed[msg.sender] = 0 |
| Interactions | Calls to other contracts, ETH sends, token transfers | token.transfer(msg.sender, amount) |
The Solidity documentation sets out the same order and suggests applying it everywhere, because a call to a contract you know can still lead to a call to one you don't (Solidity docs).
The same page widens the rule in two ways. Reentrancy can come from any call into another contract, with an Ether transfer as only one case, and in a system of several contracts a called contract can change the state of another contract you depend on (Solidity docs).
What does it look like in code?
A rewards claim written in checks-effects-interactions order (illustrative, not audited code) RewardsClaim.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
interface IERC20 {
function transfer(address to, uint256 amount) external returns (bool);
}
contract RewardsClaim {
IERC20 public immutable token;
mapping(address => uint256) public owed;
constructor(IERC20 token_) {
token = token_;
}
function claim() external {
uint256 amount = owed[msg.sender];
require(amount > 0, "nothing owed"); // checks
owed[msg.sender] = 0; // effects
require(token.transfer(msg.sender, amount), "transfer failed"); // interactions
}
}
Swap the last two lines and a token that calls the recipient during transfer lets the recipient call claim again while owed still holds the full amount.
In an audit report the finding quotes the order of two lines, such as msg.sender.call{value: amount} placed before balances[msg.sender] = 0 in a withdraw function, and the fix moves the write above the call. The reentrancy page shows that case in full.
When is the order not enough?
- The function needs the result of a call before it can write its effects, as a swap or a deposit into another protocol does, so it needs a reentrancy guard as well.
- The effect lives in another contract of the protocol, which a callback can still read half-updated.
- A loop makes a call on each pass before the updates in the loop are done.
- A view function that other protocols read returns stale numbers mid-call.
FAQ
Does checks-effects-interactions make a reentrancy guard unnecessary?
Not always, because it protects the function you order while a callback can still enter a different function that reads state you haven't updated yet. Where external calls touch shared state, use both.
Sources
- Security considerations, Solidity documentation checked 3 December 2026