I have one function in my contract which purpose is to send all funds to a second contract.
function fundOtherContract() external payable onlyOwner {
payable(otherContractAddress).transfer(address(this).balance);
}
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?