@sandeeppanda92
In the following code:
function () external payable {
uint256 tokensThatWillBeMintedAfterPurchase = msg.value.mul(rate);
if ((stage == CrowdsaleStage.PreICO) && (token.totalSupply() + tokensThatWillBeMintedAfterPurchase > totalTokensForSaleDuringPreICO)) {
msg.sender.transfer(msg.value); // Refund them
EthRefunded("PreICO Limit Hit");
return;
}
buyTokens(msg.sender);
if (stage == CrowdsaleStage.PreICO) {
totalWeiRaisedDuringPreICO = totalWeiRaisedDuringPreICO.add(msg.value);
}
}
why are you sending ETH back like msg.sender.transfer(msg.value); (which will spend the contract's own gas) instead of simply calling revert() - that will revert the whole transaction, refunding the user their ETH and gas leftovers if any.
Disclaimer: I am only learning Solidity and Ehereum smart contracts, so there is a good possibility that I am wrong. In that case, please explain me why - that will be very helpful for me.
@sandeeppanda92
In the following code:
why are you sending ETH back like
msg.sender.transfer(msg.value);(which will spend the contract's own gas) instead of simply callingrevert()- that will revert the whole transaction, refunding the user their ETH and gas leftovers if any.Disclaimer: I am only learning Solidity and Ehereum smart contracts, so there is a good possibility that I am wrong. In that case, please explain me why - that will be very helpful for me.