0
contract C1 {
   uint public num;
   address public sender;

   function callSetNum(address c2, uint256 _num) public {
      (bool res,) = c2.call(abi.encodeWithSignature("setNum(uint256)",_num));
      if(!res) revert(); // C2's num is set 
   }
}

contract C2 {
    uint public num;
    address public sender;

    function setNum(uint256 _num) public {
        num = _num;
        sender = msg.sender;
    }
}

In "JavaScript VM" mode of remix, the c1.callSetNum function operates successfully.
However, in "web3 provider" mode, It fails with the following log output:

"gas required exceeds allowance or always failing transaction."

The geth is set to private network with the chainid of 15. Version is as follows.

Geth
Version: 1.9.0-stable
Git Commit: 52f2461774bcb8cdd310f86b4bc501df5b783852
Architecture: amd64
Protocol Versions: [63]
Network Id: 1
Go Version: go1.11.5
Operating System: linux
GOPATH=
GOROOT=/usr/lib/go-1.11

And the version of the Solc compiler used is 0.5.4.

I have no idea what the problem is. Please help me.

  • If you call setNum directly does it work? – Ismael Jul 21 at 3: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.