Why does the following function not need a require statment?
function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
This function is a part of the ERC20 standard from the OpenZeppelin library.
I would have thought that this function would first need to check the allowance of the msg.sender
via a require
statement that resembles the following:
require(_allowed[from][msg.sender] <= value);
Why is this require statement unnecessary?
sub()
function (from the SafeMath library, I would guess?) reverts if the subtraction underflows. – user19510 Nov 27 '18 at 3:18