1

This question already has an answer here:

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.

marked as duplicate by Ismael, Richard Horrocks, eth Dec 11 '17 at 6:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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)

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