1
address payable receiver;

receiver.transfer(amount);

The receiver is NOT an contract, and the amount is only 0.4 ether, the contract is holding sufficient ether in its balance.

I understood that the latest solidity limits the transfer to 2300 gas, and it should be sufficient for the above operation. But why the above failed?

6
  • can you please add more information like the error log.
    – Sanjay S B
    Jan 9 '20 at 8:52
  • Sorry Sanjay, I do not aware that solidity has an error log. But in my case before I upgrade to 1.9.9, Truffle v5.1.7, every thing was working perfectly. In the latest version works well when I commented out the transfer(). So it has to be due to the gas limit, or some other reason which I do not know.
    – s k
    Jan 9 '20 at 9:45
  • 1
    are you trying this on your development instance or a test network? how did you know that it failed? You must have seen some error somewhere. You should share how you concluded this line failed. You have just posted two lines of code and that the line is not working. I am sorry I don't have the ability to guess what you are trying to do from this information
    – Sanjay S B
    Jan 9 '20 at 9:50
  • This fixed the problem consensys.github.io/smart-contract-best-practices/… (bool success, ) = receiver.call.value(amount)(""); require(success, "Transfer failed.");
    – s k
    Jan 9 '20 at 12:44
  • why would that fix the problem? Very puzzling since you say receiver is not a contract address... Jan 9 '20 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.