1

Using Solidity 0.4.18. If I send ether to a payable function, and the function does some of its stuff, and then throws (via require), what happens to the ether that was sent to it? Does the ether stay in the contract?

Edit: I know that "throw" reverts transactions - I wanted to know whether "require" does the same.

2

When a contract is firing an exception (via throw / require / assert), the transaction and all change to the state are reverted . So the ether that you sent to this function will not be transferred .

Internally, Solidity performs a revert operation (instruction 0xfd) for a require-style exception and executes an invalid operation (instruction 0xfe) to throw an assert-style exception. In both cases, this causes the EVM to revert all changes made to the state.

(from official doc)

|improve this answer|||||

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