Skip to main content

What Alternative to Transfer Is Recommended for Sending Ether Securely in Modern Solidity?

The recommended alternative is to use the low-level call function combined with the Checks-Effects-Interactions pattern and an explicit gas limit of zero, or a very low, safe amount. A common secure pattern is (bool success, ) = recipient.call{value: amount, gas: 0}("");.

By limiting gas or ensuring state is updated first, the risk is mitigated without the fragility of the 2,300 stipend.

Can the CEI Pattern Be Applied to Other Security Vulnerabilities besides Reentrancy?
How Have Recent Versions of Solidity Changed the Behavior of Fallback Functions to Mitigate This Risk?
What Is the Difference between a Receive() and a Fallback() Function in Solidity?
What Would Be the Vulnerable Code Structure That Violates the CEI Pattern?