0

I have the following solidity contracts defined. I want to test nested calls using the lowlevel api where C->D->E. However, running this code passes on ganache-cli but fails on geth --dev node. Im using remix to run the transaction, any help is appreciated

pragma solidity ^0.5.12;

contract D {
  uint public n;
  address public sender;
  event GotPaid(address _sender, uint256 _value);


  function callSetN(address payable  _e, uint _n) payable public {
    //address payable e = address(uint160(address(_e)));
    _e.call.value(msg.value)(abi.encodeWithSignature("setN(uint256)", _n)); // E's storage is set, D is not modified 
    emit GotPaid(msg.sender, msg.value);
  }

}

contract E {
  uint public n;
  address public sender;
  event Update(uint256 num);
  function setN(uint _n) payable public {
     n = _n;
     emit Update(_n);
  }

}


contract C {

    function foo(address payable _d, address payable _e, uint _n) payable public {
      address(_d).call.value(msg.value)(abi.encodeWithSignature("callSetN(address,uint256)",_e,_n));
    }

}

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.