Termination
1 min read
Pronunciation
[tur-muh-ney-shuhn]
Analogy
Think of a computer program running. 'Termination' is when the program finishes its task successfully and closes, or when it crashes due to an error or if it's forcibly stopped. For smart contracts, successful termination commits state changes, while error termination usually reverts them.
Definition
In smart contract execution, termination refers to the point at which the execution of a contract's code for a given transaction or call concludes. This can happen normally upon completion of all instructions, or abnormally due to an error, an explicit revert, or running out of gas.
Key Points Intro
Termination marks the end of a smart contract's execution cycle for a particular interaction.
Key Points
The end of a single execution context of a smart contract function.
Normal termination: the contract code completes successfully, and state changes are typically committed (if it's the outermost call).
Abnormal termination: can occur due to errors like `revert`, `assert` failures, invalid opcodes, or out-of-gas conditions. State changes are usually rolled back.
The `SelfDestruct` opcode is a specific form of termination that also removes the contract's code and storage from the state.
Example
A smart contract function designed to distribute funds might terminate normally after successfully sending payments to all recipients. If it tries to send funds to an invalid address and encounters an error causing a `revert`, it terminates abnormally, and any prior fund transfers within that same transaction are undone.
Termination - Related Articles
No related articles for this term.