Skip to main content

How Does a Storage Variable Update Relate to the “Effects” Stage of the CEI Pattern?

The "Effects" stage of the Checks-Effects-Interactions pattern specifically refers to updating the contract's state variables, which are stored in the contract's storage. In the context of a withdrawal, the critical effect is setting the user's balance to zero or deducting the withdrawal amount.

By performing this storage update before the external call, the contract ensures that a re-entry attempt will see the updated, lower balance, thus failing the check.

How Does the Checks-Effects-Interactions Pattern Prevent Reentrancy Attacks?
Give an Example of a State Variable in a Smart Contract Used for Collateralized Lending
What Is the Checks-Effects-Interactions Pattern and How Does It Prevent Reentrancy?
How Did the DAO Hack in 2016 Utilize a Reentrancy Attack?