When a buyer calls a buy
function on dapp contract, some dapps check the buyer's allowance before transfer tokens(erc20). Is it usual?
If the dapp is transferring tokens on the user's behalf (i.e. calling transferFrom()
), then the dapp must check if the user has the proper allowance
.
In order to use transferFrom()
, the user must allow a contract to spend tokens on their behalf. To do this, the user must first approve()
a certain amount of tokens that they are willing to the let the dapp transfer. The dapp must confirm that the user has an adequate allowance()
before calling the transferFrom()
function, or else it will fail.
If a simple ERC20 transfer()
is being made, then this does not matter.