Contract storage is a key of 32 bytes and a value of 32 bytes, so the maximum a single contract can store is around 1.46 GB (32^32).
False. There are 2^256 different keys, and each key can store 32 bytes, so that's a total of 2^261 bytes that could be stored. That said, by then the Ethereum blockchain will probably break due to a hash collision....
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.
Best Answer
Yes, it's possible. The following code does just that if you were to call the
create
function on a deployedCreator
:The refunds are only processed after the transaction is executed, in go-ethereum : transaction execution followed by refund. So you must provide the whole cost upfront, but it will only cost you that amount minus the refund.
Refunds are no longer as interesting as they used to economically speaking (see EIP-3529), plus for anyone to profit on it there needs to be some variation (i.e., time delay) between the creation and selfdestruct, that is not the case if everything happens inside a single transaction.
I hope that answers your question.