Ordering of _transfer and _approve in ERC20 transferFrom?


I cannot see any logic behind transfer.

  1. It calls transfer
  2. It call approve

Shouldn’t this be the other way?

  1. Approve (and fail if there’s not enough allowance)
  2. Transfer
1 Like

Hi @dmdv,

Welcome to the community :wave:

In the case of ERC20 , the order is irrelevant because _transfer and _approve are independent and never call any other contract: they are executed atomically.

However , this is very relevant for users that intent to override _transfer or _approve with their own implementations: we should be clear about the order in which these things happen.

See: https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2030#issuecomment-568487500

1 Like