7

I learnt from the yellowpaper that at the end of a contract execution, there could be a list of suicide accounts that will be removed.

my question is, why and how would one smart contract remove other accounts (smart contracts).

for example, I understand the need of self destruction. when one smart contract is finished, it destructs itself. but why do you need to destroy others and how?

Can my smart contract destroy a contract owned by another person?

also, engineering wise, how this destruction is implemented? for example, do we actually modify previous blocks' contents related to destructed accounts? or we just update the change in the tree structure?

7

To start my answer, I have to say that once you put something on the blockchain it is "immutable", and by that I mean that it can not be modified or deleted.

(there is a special type of "upgradable" contracts but this is not the answer for that)

You can find here a lot of information about self-destruction.

Why would you need to destroy others? For example, to make a contract not accessible, you can not delete it from the chain but you can disable it.

Can my smart contract destroy a contract owned by another person? This requires a long explanation and has multiple factors at play. But, in summary, no, you can't do it.

How is this destruction implemented? You can use selfdestruct/destroy (The old mean suicide/kill). You can find some information here and a good but old tutorial here - the latter explains how this implementation works. Also, here's yet another link with information on the topic.

Do we actually modify previous blocks' contents related to destructed accounts? or we just update the change in the tree structure? We never can modify other blocks, we can only put a new block in the blockchain with more information. Blocks are permanent and they contain the information of the transactions and the contracts. Maybe this can help you with the block concepts.

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.