Imagine I have a function that looks something like this. Is the ether refunded to the sender (invoker) if require fails?
function foo(uint _minShares) public {
uint256 ethReserveBeforeDeposit = address(this).balance - msg.value;
// compute proportion of deposited ether and total ether balance to determine amount of shares
uint256 sharesMinted = (msg.value / ethReserveBeforeDeposit) * totalSupply();
require(sharesMinted >= _minShares);
// what happens if require fail, is msg.value refunded?
}
Best Answer
Just tested it out on remix.ethereum