If you are looking for an alternative of throw
, you can use revert
in the similar way. The revert
function can be used to flag an error and revert the current call. As stated in solidity docs :
Note
There used to be a keyword called throw with the same semantics as revert() which was deprecated in version 0.4.13 and removed in version 0.5.0.
From code point of view, you can use the require
as below:
function createTokens() payable {
require(isMinting == true && msg.value > 0);
uint256 tokens = msg.value.div(100000000000000).mul(RATE);
balances[msg.sender] = balances[msg.sender].add(tokens);
_totalSupply = _totalSupply.add(tokens);
owner.transfer(msg.value);
}
So if isMinting
is not equal to true
, it will throw straight from there without making any changes in the state.