Skip to main content

What Is the Checks-Effects-Interactions Pattern?

The Checks-Effects-Interactions (CEI) pattern is a smart contract coding standard designed to prevent reentrancy attacks. It dictates that a function should perform all necessary Checks (e.g. input validation, access control) first.

Then, it should execute all Effects (e.g. updating state variables like balances) internally. Finally, it should perform any Interactions (e.g. external calls to other contracts or sending Ether).

By updating the state before making external calls, the contract is protected from a recursive call-back.

How Does a Storage Variable Update Relate to the “Effects” Stage of the CEI Pattern?
How Does the Checks-Effects-Interactions Pattern Prevent Reentrancy Attacks?
What Is a Common Vulnerability Found in Smart Contract Code?
Can a Reentrancy Attack Be Performed without a Fallback Function?