0

I don't think I understand the process of minting tokens. As far as I understand, a contract that creates a token has full control and governance over the token (creation, destruction, transactions) any contract that wants to interact with the token will have to interact with the tokens smart contract.

If that assumption is correct, then can I add a selfdestruct method to a tokens contract directly, and if so what happens to its tokens after this method is called?

But if this assumption is incorrect, I'd greatly appreciate being enlightened, and also how are other contracts and wallets able to interact with a token?

1 Answer 1

0

As far as I understand, a contract that creates a token has full control and governance over the token (creation, destruction, transactions) any contract that wants to interact with the token will have to interact with the tokens smart contract.

That is correct, it's just that a contract doesn't "create" a token, a token IS a smart contract.

then can I add a selfdestruct method to a tokens contract directly

You can, but it's highly discouraged as 1) For anyone to interact seriously with your token you'll need to verify it and therefore expose the source code. 2) Any token with a potential call to self-destruct or anything potentially sending all the balance to the owner (a rug pull) will never see meaningful activity. Self destruct has nothing to do in a token, and actually has nothing to do on a blockchain, it's likely that it will be neutralized in the near future.

if so what happens to its tokens after this method is called?

Self destruct will forward all the contract balance to a specific address, and then the contract code and storage will be cleared. So no more interaction will be possible.

You can put selfdestruct in a token contract, but don't. It's a strong sign of bad practice / design at best, and a honeypot at worst.

2
  • Thank you! Just for clarification, the tokens that are in users wallets will just disappear? So in order for you to see your balance of tokens this would require a method call to the token contract, so if the contract no longer exits then you would not be able to see the balance?
    – SocaBlood
    Commented Dec 13, 2021 at 22:03
  • I guess that depends on how the UI is implemented (caching, etc..) but overall, you couldn't read your balance as there would be no contract, and no storage. If you try the method call anyway it would just revert.
    – hroussille
    Commented Dec 13, 2021 at 22:20

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.