0

Let's say I asked a user to approve the X Dai amount today for Smart invoice asking price.

daiContract.methods.approve(cAddress, X.toString()).send({
    from: ethereum.selectedAddress
});

But, he buys after a week since the time he approved. so, the asking amount increases with the time Y Dai so, he has to approve extra dai amount Z Dai = Y Dai - X Dai

daiContract.methods.approve(cAddress, Z.toString()).send({
    from: ethereum.selectedAddress
});

but it is overriding the previous X Dai amount and giving some random amount when I check the allowance

daiContract.methods.allowance(ethereum.selectedAddress,cAddress).call({
        from: ethereum.selectedAddress
    }

so, what happens when I approve multiple times and does it add like if I approve X Dai first-time transaction and then Y Dai second time approves the transaction = X Dai + Y Dai? or it completely overrides the first and now only Y Dai is approved?

2

1 Answer 1

1

Each approve method in ERC20 token standard rewrites the previous approved amount. Method transferFrom is decreasing the approved amount on each transfer. For example if I approve my someone to spend 1000 of my tokens, but then for some reason I wan't to decrease that amount to 300 I will just call approve method again and pass amount 300 as parameter (1000 now will be replaced by 300). If I wan't to fully disable this someone to manage my tokens I will pass 0 as parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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