Solidity theorytheory 0/50 · 0%
Value transfer · medium

24. Sending ETH safely

transfer, send and call — and why call wins.

`transfer` and `send` forward only 2300 gas, which breaks with contracts whose `receive` does real work. The modern default is `call` with an explicit success check, combined with reentrancy protection.

(bool ok, ) = payable(to).call{value: amount}("");
require(ok, "ETH transfer failed");

Better still, prefer the pull pattern: record what someone is owed and let them withdraw it themselves.

Check your understanding

  1. 1. How much gas does `transfer` forward?

  2. 2. What must you always do after `call{value:}`?

  3. 3. What is the pull payment pattern?