Solidity: A Small Test of the Self-Destruct OperationPosted by Carpentry on November 27th, 2021 About the opcode that is generated at the compilation of the
Below you will find a small toy example that contains the smallest amount of logic to make some tests. It is easily executable using so you can try it even without installing the development environment. The first method to test is store, which will just store the integer value passed as a parameter in the internal state of the smart contract.send self destruct transfer The next method to test is retrieve, which, as the smartest among you might already have figured out, retrieves the value stored beforehand in the internal state. Calling this method before actually storing anything will just return 0 because the variable is zeroed by default. From now on, each interaction with the smart contract will be successful but still will not do anything. Invoking the From now on, each interaction with the smart contract will be successful but still will not do anything. This is, in a way, an inconsistency: The client that invokes the smart contract is not aware of the fact that the smart contract has been destroyed. For instance, in this particular smart contract, calling the Like it? Share it!More by this author |