2

I seem to get a revert each time I try this. I'm unable to get any useful revert message from truffle, so any assistance there might also help solve this.

I have a library:

library LibInterface {
  ...
  mine(address who){
     ...
  }
  ...
}

which I call

contract MyContract {
  ...
  function mine(address who) public payable{
    s.mine(who);
  }
  ...
}

Removing the payable flag or simply not sending funds via truffle test will stop the revert. Removing the library call or simple calling another non-library contract also succeeds.

Any ideas? Is this disallowed? Why?

  • 1
    Definitively you are allowed to call libraries from payable functions. It is not this the problem. – Rick Park Oct 29 '18 at 8:06
  • Agree with @RickPark, the problem is somewhere else. If you take the sample code from solidity.readthedocs.io/en/v0.4.24/contracts.html#libraries and add payable to the function register, it works perfectly – Marco Ottolini Oct 29 '18 at 8:12
  • Is there any condition inside the function you are calling in the library that might possibly be the source of the revert? Maybe a require that was not satisfied? – vhie Oct 29 '18 at 8:27
  • Does the library function happen to do something like require(msg.value == 0)? – goodvibration Oct 29 '18 at 9: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.