What is a smart contract?
A smart contract is a computer protocol intended to digitally facilitate, verify or enforce the negotiation or performance of a creditable transaction with the terms of an agreement between buyer and seller is directly written into lines of code. The code and the agreement contained therein exist across a distributed, decentralized Blockchain network. Smart contracts permit trusted transactions and agreements to be carried out among different anonymous parties without the need for a central authority, legal system or external enforcement mechanism. They render transactions that are traceable, transparent and irreversible.
Are smart contracts reversible?
One of the main reasons people are embracing smart contracts is their ability to prevent any tampering with transaction code once the transaction has been completed. Just like any other Blockchain transactions, Smart contracts are almost impossible to tamper with. Contracts deployed on a Blockchain are immutable which means that once a contract is in the Blockchain it is final and the address and the code cannot be changed or modified. Specific parameters, however, can be adjusted only if they are allowed to change via the original code.
However, there are certain ways that you can update or modify a smart contract which we are going to explore below.
Methods of updating smart contracts.
One way to update the code is to create an intermediary Smart contract that will hold the address of the active smart contract. So all the calls and transactions will be redirected to the active version with the function DELEGATECALL. That way you will be using the same contract address, but that contract will execute a different smart contract code in the end. This way you could have a contract that maintains the same address and storage, but forward all calls to an address stored in a variable. Note that there are essential security risks when delegating calls and that you have to be extra cautious when designing upgradable smart contracts.
Another way is to extract all the information from the old contract and insert it into a new version, then update the address that your users will see.
Another method is to put your logic code in a library, then use the CALL CODE feature, via libraries in solidity to call the address. This way user data persists between versions. However, this has the limitation that the ABI of the logic contract must stay the same over time.
Not only are smart contracts secure but also faster and they do not require a third party. Since they are based on Blockchain technology, smart contracts cannot be changed. However, people had to come up with ways to modify these contracts to make their modification as well as improvement possible. Entirely changing the original code and its address may not be possible however that does not mean nothing can be done.