Skip to main content

How Does the Use of Transfer or Send Help Enforce the CEI Pattern?

The use of the Solidity functions transfer() and send() for sending Ether helps enforce the CEI pattern by limiting the gas forwarded to the recipient contract to 2300 gas. This gas limit is typically insufficient for the recipient to execute a complex state-changing function, which is necessary for a reentrancy attack.

By effectively preventing a recursive call, these functions act as a simple, built-in reentrancy guard for the Ether transfer part of the Interactions step.

How Do Gas Limitations Prevent Reentrancy in Some Cases?
Why Might a Stop-Limit Order Fail to Execute Completely?
What Is the Difference between Gas Limit and Gas Price?
How Can an Attacker Force an External Call to Return False without Reverting?