'ERC20 token contract: does approve function need to check caller balance?
I'm reading ERC20.sol source code. There's a question about the approve function.
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
In the function, it requires owner != address(0) and spender != address(0). I just wonder should we do the amount check in the function? Such as:
require(amount <= _balances[owner]);
Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
