-1

When calling a contract like this :

if(!contractname.somefunction()) throw;

It both checks the stack (which checks if contract call’s fails) and if the contract call succeeds but returns false in memory.

But when using .value() or .send() it only checks if the contract calls fail, which means it doesn’t check for the return value in memory.

So how to check for a return value in memory while still sending Ethers ?

StillFantasy
  • 1,677
  • 9
  • 21
user2284570
  • 2,891
  • 3
  • 26
  • 74

1 Answers1

-1

A good way is via Events. For that somefunction(), you can have something as below:

contract Contractname {

  event ReturnValue(uint);

  function somefunction(){
    uint result;

    //...some computation right here

    emit ReturnValue(result);
  }

}

It's not possible to send Ether while getting the return value back as the same time.

Jeff Hu
  • 714
  • 1
  • 8
  • 20
  • Sigh ! Events can’t be checked from contract code which is the point of the question… Now unlike what I wrote, `.transfer()` does both. – user2284570 Nov 07 '19 at 22:38