- require() is a convenience function used to check conditions and throw an exception if a condition is not met.
- Earlier versions of solidity (prior to 0.4.13) used the throw pattern to revert the state during an exception. It is deprecated now and will be removed in a future version:
// Older and deprecated methodif (msg.sender != owner) { throw; }
- Use the require() method to ensure conditions such as inputs are valid, or to validate return values from calls to external contracts:
require(toAddress != address(0));require(targetContract.send(amountInWei));require(balances[msg.sender] >= amount);
- Return an error message or a number corresponding to an error type using require():
require(condition, "Error Message");
- The function ...