Roadmap › Solidity & Smart Contract Development › Module: Object-Oriented Solidity
Lessons in this course (11)
7. Sending and receiving Ether safely
Intermediate★ Must knowLesson 7 of 11
solidity
// Recommended: call with checks-effects-interactions + reentrancy guard
(bool ok, ) = payable(to).call{value: amount}("");
require(ok, "ETH transfer failed");
// transfer/send forward only 2,300 gas — can break with smart-contract wallets; generally avoid
payable(to).transfer(amount); // reverts on failure
bool sent = payable(to).send(amount); // returns false on failurePull over push: instead of sending Ether to many users in a loop (one failing recipient blocks everyone; gas limits), record balances and let each user withdraw().