I have one function in my contract which purpose is to send all funds to a second contract.

   function fundOtherContract() external payable onlyOwner {

Then, my other contract has following to successfully retrieve funds sent to it:

    receive() external payable {
        require(stateVariable[currentId].status == Status.Open);
        stateVariable[currentId].amount += msg.value; //Here is where it fails

That currentId is also a state variable.

When calling fund Other I get a gas estimation fee warning and the transaction reverts.

I assume the problem is I cannot access msg.value there?

Is there any way to retrieve the value being being received and store it?

  • Are you positive that the require statement in your function isn't failing?
    – natewelch_
    Commented Jul 20, 2022 at 4:07

1 Answer 1


gas is limited to 2700 for transfer and send and they are deprecated.


(bool ok,) = otherContractAddress.call{value: address(this).balance}("");
require(ok, "transfer failed");

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.