This is taken from OpenZeppelin's ERC20 transferFrom
implementation:
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
Is there a reason why _transfer
is called prior to checking the withdrawer (msg.sender
) allowance?
Would transferFrom
still work correctly if the allowance require
check was done first instead?