2

In ERC20 we approve a user to spend our token and then they can spend as much allowed using transferFrom, but if the allowance limit exceed then I have to approve again, is there any way to allow them to spend all tokens? I mean have to approve a account only once

1

What is usually done (you can see such cases on decentralized exchanges) is to approve a very large number of tokens (greater than the total supply). A library such as bignumber.js can help you to work with this kind of numbers in javascript.

Note that this approach may involve security concerns. If the smart contract has a weakness and is "hacked", the attacker could potentially steal all of the users' tokens. One can reduce this risk in their dApp by implementing a "disapprove" feature which is an approval of 0. Indeed, each call of the approve method overrides the previous value.

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.