hope you can assist me on this scenario
few months ago a token has been created and dispatched to several wallet. Right now, the developer wants to add some better features for the users.
The users need to send same amount (let's call it 100) tokens to a new contract, where those 100 tokens are swapped for 100 new tokens.
The caveat is that the developer has lost a wallet holding some amount (about 30,000 tokens) of tokens which he would want to exclude from getting the new tokensin case if is found by someone.
Now the question is;
- How can a new contract receives X amount of old tokens.
- How can the amount sent be checked and send back new tokens of same value?.
- How restrict a particular wallet from getting the new tokens
So basically, i'm looking for a way to swap new coins from the old contract and exclude a particular wallet address..
(if you can also add a standard code too)
Thank you for helping me out 🙂
Best Answer
Unfortunately, I cannot comment on flygoing's answer, but here's a few things to notice:
Withdraw old tokens balance by calling
oldToken.trasnferFrom
. Consider burningoldTokens
, if appropriate, or send it toaddress(this)
. It'll allow you to perform double checks and ensure correctness.After exchanging
oldToken
consider checking changes of "before" and "after" balances. Do not blindly trustoldToken.trasnferFrom
return value, checkoldToken.balanceOf
explicitly.