Are smart contracts reversible?
June 14, 2021
If you are somewhat familiar with blockchain technology, you might have already heard about smart contracts. Although the basic idea of smart contracts existed since the 1990s, they gained popularity with the rise of Ethereum. In recent years, smart contracts have been pivotal to innovations in the blockchain-cryptocurrency domain, potentially transforming businesses and lives worldwide.
As such, the underlying technology makes smart contracts immutable, which is one of their significant upsides. Yet, several hacks, scams, and consequent monetary losses have occurred in the past, despite claims to enhanced security. As a means to damage control, some have suggested the reversal of affected smart contracts. Others, however, have seen this as a threat to the promise of smart contracts to be tamper-proof.
So, then, the pertinent question is this—are smart contracts reversible? Or, are they not? In this article, we intend to provide some answers.
Smart Contract Definition & Functioning
Before we try to answer the question "are smart contracts reversible?", it’s essential to understand what are smart contracts. The definition below is a brief idea of smart contract to gasp the essence of it but you can hop to other articles where we covered all details including functioning and smart contract use cases for FinTech or smart contract audit.
So, we know what blockchain based smart contracts are, but how do they work? As opposed to traditional transaction, smart contracts do not involve third parties to make a creditable transaction. The trust is guaranteed by maths and algorithms, which typically are unbiased. All the functions performed by the anonymous parties can be coded into the smart contract.
The popular expression is that smart contracts work like vending machines. To understand this better, we can use another example–suppose that Julia wants to send 1 BTC to Adam every day from a wallet that has 10 BTC. She can do this manually, but it’s much easier if it is automated; a smart contract serves the purpose. Every day, the contract can transfer the said funds from Julia’s wallet to Adam’s at a predefined hour. Furthermore, once deployed, neither Julia nor Adam can change the contract terms, which effectively secures both involved parties.
Obviously, this is a basic description of this self-executing and self-enforcing computer protocol. There is an advanced technology behind it and if you want to dive deeper into it, we suggest reading our blogpost Smart Contract For Fintech - Definition And Use Cases written by our blockchain developers.
Vulnerability of Smart Contracts: Are Smart Contracts Reversible?
Smart contracts have immense potential for overcoming the recurrent lapses of traditional contracts ( intermediated agreements); mitigating conventional breaches is also their motive. The idea is excellent they perform credible transactions, but ordinary smart contracts cannot promise absolute security.
As algorithmic protocols, they are vulnerable to coding errors, bugs, and hacks; these are somewhat common. Bugs in smart contracts are highly problematic because, among other things, they can result in substantial loss of funds. Time and again, users of Ethereum, Gate.io, and Krypton, among others, have lost millions of dollars to flaws in smart contracts. Therefore, issues linked to security smart contracts is the priority for business owners as well as for blockchain development companies.
Moreover, 51% attacks pose severe threats to the immutability and reliability of a network’s smart contracts. In such events, attackers gain control over a majority of the computational power, enabling them to manipulate or reverse transactions, as well as smart contracts. Although theoretical, this is a possibility; we thus arrive at our central question—is it possible to reverse smart contracts?
On principle, smart contracts are, in fact, irreversible. But there are times when the irreversibility has been challenged, seemingly for the greater good. Consider, for instance, the infamous DAO Attack of 2016, where attackers siphoned off nearly $60 million. The attack was due to a vulnerability in the smart contract. Still, the eventual ‘solution’ has more gravity in the present context. The community voted for reversing Ethereum’s transaction history until the hack; to this end, a hard fork was the only way. In effect, this amounted to a reversal of Ethereum’s smart contracts, although not by definition.
The Forkless Algorand: Securing Smart Contracts
So, hard forks are a possible means of reversing smart contract outcomes, which is a problem. The solution, then, is to have a forkless blockchain, such as Algorand. That is not to say that one has to live with a compromised smart contract. Should the contract creator allow modifications, it is possible to replace the smart contract with a newer version, this resolves the crisis while preserving the domain’s ideals. The modification can of course happen through decentralized means, for example by a vote in a decentralized organization.
Apart from being forkless, the likes of Algorand have other features that help minimize risks related to smart contract vulnerabilities. Let’s look at some of them.
A Robust Code
The foremost and most obvious requirement is writing clean, bug-free, and secure code. Not only that, testing must be adequate to eliminate the possibility of human errors optimally. Thorough testing also helps developers confirm the resilience of the smart contract’s cryptography, which is pivotal to security. Dedicated to this purpose, Algorand has laid down the guidelines to develop cutting-edge smart contract's blockchain.
Instant Block Finality
Algorand eliminates the issues that proof of work blockchains have with finality. On Algorand once a transaction is added to a block and committed to the blockchain it is final and automatically enforced. What this means for a business, is that once they observe a result of smart contract execution on the blockchain, it can be considered unchangeable. Practically, this allows network participants to act on the result of a smart contract as early as it is added to the blockchain, without the need to wait a set amount of blocks before the transaction can be deemed final.
Consensus Algorithm & A Strong Community
A robust consensus mechanism secures the network as a whole, and its effects trickle down to the associated smart contracts. Most older blockchains, including Ethereum, either uses Proof-of-Work (PoW) or a hybrid consensus mechanism. On the other hand, Algorand uses a Pure-Proof-of-Stake (PPoS) method, whereby voting rights are proportional to staked $ALGO tokens. Validators have their skin in the game at all times. 51% attacks are impossible on blockchains using PoS consensus, however, they have their own shortcomings, for example, an attacker controlling ⅓ of the total stake can stall a blockchain (preventing a consensus from ever being reached) and an attacker controlling ⅔ of the stake has complete power over the consensus.
A strong and active community augments the security of the consensus mechanism; The bigger the stake, the harder it is for an attacker to acquire over ⅓ of the total stake. Furthermore, the community ensures constant vigilance, allowing early detection of attackers trying to compromise the network. Able members can also be on the lookout for bugs in smart contracts and notify the smart contract developers about them.
Building Secure Smart Contracts
We have arrived at the end of our discussion, but something remains. Blockchain ecosystems are usually open-source, and so is Algorand. If you have the required resource, you can build smart contracts on your own using existing code. But this has problems; one, there’ll be limited scope, and two, the chances of error are high.
While smart contracts can be so powerful and execute endlessly without overseeing them, building them requires extra care. On Ethereum, that requires extremely skilled developers and a professional smart contract code audit–that can cost anything around $300,000, and more.
For a smoother and cost-efficient smart contract building, we advise building on Algorand. Using this technology ensures that even in such serious cases as Decentralized Autonomous Organizations (DAOs), smart contracts are irreversible and secure. Developers may, however, also choose to build upgradeable smart contracts in case they intend to leave room for updating them in the future.
At Ulam Labs, we are blockchain native and as an official Algorand development partner, we specialize in building blockchain solutions on top of that technology. Our mission is to support the decentralized revolution by lowering the barriers of implementation of new ideas to a minimum using blockchain technology.