0
contract one{

unint number;

function saveNumber(unint _number){ number = _number; }

}

contract two{

function callOtherFunctionAndAlsoTransferFunds(){

oneContract = one('contractaddress');
oneContract.saveNumber(6);
assert(msg.sender.transfer(10000000));


}    
}

The line I am concerned about is

 assert(msg.sender.transfer(10000000));
  • Can I do this ?
  • If this throws an exception, will the internal transaction that called contract one also be reversed ?

1 Answer 1

1

First, if you are interested in checking the return value from ether transferring operation you should use send method instead of transfer which is meant to throw an exception on failure.

 assert(msg.sender.send(10000000));

Referring to your question:

If this throws an exception, will the internal transaction that called contract one also be reversed ?

Yes, all of the state changes are going to be reverted when transaction throws an error. This is done regardless of whether the methods are called inside one or several contracts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.