1

On CrytpoKitties, when I tap the buy button in a market, MetaMask comes up and shows if I can buy or not based on allowance instantly. How is this possible? Is it making query? Is it included in kitty's contract?

0

Yes, Metamask is checking if you have approved the tokens to be spent by the Cryptokitty smart contract.

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.

  • I had never sent any tx like approve. After login via metamask, I tapped the buy button, then checking allowance comes up. – yseek May 20 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.