Skip to main content

What Is the Checks-Effects-Interactions Pattern and How Does It Prevent Reentrancy?

The Checks-Effects-Interactions pattern (CEI) is a security best practice for writing smart contracts. It dictates that all input validation (Checks) should happen first, followed by state changes (Effects), and finally, any interaction with external contracts (Interactions).

By updating the state (Effects) before the external call (Interactions), the contract prevents reentrancy, as the balance is zeroed out before the malicious re-entry attempt.

How Do Solidity Modifiers like Nonreentrant Implement the CEI Principle?
How Does the Checks-Effects-Interactions Pattern Prevent Reentrancy Attacks?
How Is the Call Function in Solidity Related to Reentrancy?
How Can Reentrancy Attacks Be Prevented in Smart Contracts?