From ceecfcb8a33ec26ea210beaf7b34ebbaa9203c8d Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 20 Jan 2021 11:14:27 +0100 Subject: [PATCH] Fix payable example. --- docs/contracts/functions.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index 6aaa9d245..10c2c9ed2 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -438,7 +438,10 @@ operations as long as there is enough gas passed on to it. // results in test.x becoming == 1 and test.y becoming 1. // If someone sends Ether to that contract, the receive function in TestPayable will be called. - require(payable(test).send(2 ether)); + // Since that function writes to storage, it takes more gas than is available with a + // simple ``send`` or ``transfer``. Because of that, we have to use a low-level call. + (success,) = address(test).call{value: 2 ether}(""); + require(success); // results in test.x becoming == 2 and test.y becoming 2 ether. return true;