I am reading OpenZeppelin's Escrow.sol smart contract. The withdraw function's comment says: "Withdraw accumulated balance for a payee, forwarding all gas to the recipient.". What does forwarding all gas here mean?

1 Answer 1


As you can see in the withdraw function, it calls payee.sendValue(payment);. The sendValue function is declared in the Address library. And as we can see, it sends the balance using the .call function.

Based on the documentation, the .call function forwards all the gas to the recipient. This is ideal in case a recipient is also a contract that wants to run some other logic and this way it does not run out of gas.

As you can also see from the documentation, the .transfer and .send function only forward 2300 gas, which is enough to receive ether, but not enough to do more complex operations while receiving the ether, like modifying the state of the recipient contract.

That's why it says that is forwarding all the gas to the recipient, because it's sending the eth using the .call function instead of the .send or .transfer functions.

The gas that is not used by the recipient is returned to the sender contract, and the gas that it does not use is then refunded to the original sender. This way, previous senders can continue doing more operations.



Address library:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.