Homecryptocurrency News

    Explained: Life cycle of smart contracts on a blockchain

    Explained: Life cycle of smart contracts on a blockchain

    Explained: Life cycle of smart contracts on a blockchain
    Profile image

    By CNBCTV18.com  IST (Published)

    Mini

    While Ethereum used the same underlying blockchain technology as bitcoin, what made all the difference was the use of smart contracts on the Ethereum network.

    The Ethereum network founded in 2013 by programmer Vitalik Buterin along with other crypto enthusiasts has managed to steal the limelight from bitcoin for a while now. The primary reason for this was that the Ethereum network could be used for multiple applications, unlike bitcoin.
    While Ethereum used the same underlying blockchain technology as bitcoin, what made all the difference was the use of smart contracts on the Ethereum network. Let’s delve a bit deeper into the concept of smart contracts and how they are executed on the blockchain.
    What are smart contracts?
    As mentioned above, Smart contracts were first introduced on the second-generation Ethereum blockchain. These are nothing but programs that are designed to execute when certain predefined criteria are met on the blockchain. The objective of having smart contracts is swift execution, without intermediaries, and automation.
    Smart contracts consist of three primary components:
    • A contractual arrangement between parties
    • The governance of set conditions in executing contractual obligations
    • Implementation of the contract
    • The code that powers smart contracts incorporates set ‘if/when…then…’ conditions to make the contract work on the blockchain. When these criteria are met, the contractual activities are executed by programs on decentralized applications or dApps. The coding language for smart contracts on the Ethereum blockchain is called Solidity, a Turing-complete language.
      The potential activities that can be run using smart contracts include payment transfers, vehicle registrations, sending alerts, ticket issuances, etc. The blockchain data is updated as soon as the selected transaction is completed. Such a framework ensures that it cannot be manipulated by third parties and can only be viewed by the parties partaking in the transaction.
      What is the foundation for these smart contracts?
      The decentralized ledger system created on blockchains, and the native cryptocurrency of the network serve as the pillars upon which the system of smart contracts banks. As the security and privacy of the transacting parties must be ensured, the blockchain-powered digital ledger system is critical. The data of individual transactions get sequentially bundled and stored on the blocks of the blockchain. The elimination of central oversight contributes to the security and tamper-proof nature of such transactions.
      The phases of a smart contract lifecycle:
      Unlike a blockchain’s lifecycle that begins with the identification of a problem and ends with a blockchain that resolves the issue, a smart contract on the blockchain undergoes different phases. They are as follows:
      Create:
      Contract negotiation and reiteration constitute a significant part of the first phase. The involved parties must arrive at a consensus about the terms being listed in the contract. It is very similar to the traditional contract negotiations that we are accustomed to doing physically, just maintained digitally.
      Contract participants must also have a wallet on the blockchain being used to draw up the smart contract. Once the contents of the contract have been finalized, they must be codified. Due to the personalized nature of each smart contract, codification sometimes becomes difficult. Most blockchain developers, therefore, provide the means to test the behavior of a smart contract upon creation to mimic the actual behavior of the same.
      This multi-iterative requirement often warrants increased communication between transacting parties and the programmer. Upon mutual agreement of the terms after codification, the smart contract is uploaded to the blockchain network and becomes irreversible. If the terms need to be modified again, a new contract needs to be created.
      Freeze:
      Transactions on a blockchain are validated by a set of computers across the network called nodes. These nodes are nothing but blockchain miners who devote the computing power at their disposal to ensure fair governance of the smart contract. In return for their services, a small fee is given to these miners as well. This framework ensures that the blockchain only has legitimate contracts and isn’t clogged by bogus entries.
      During the ‘freeze’ phase, the contract and its participants become open to the public on the public ledger. Any sort of funds transfer is blocked during this period as the nodes act as a governing body that verifies whether the preconditions for contract execution have been satisfied.
      Execute:
      The integrity of a smart contract is verified by the authenticating nodes, and the contract’s interference engine (or the compiler) executes the code. When the inputs from one party are received in the form of coins (as a commitment of goods to be exchanged), the interference engine creates a transaction triggered by the met criteria.
      The new transaction data is then added to the blockchain and is once again verified by the governing nodes to ensure fulfillment according to the agreed-upon terms in the contract. This verification process is governed by the ‘consensus mechanism,’ i.e. Proof-of-Work (miners pledge computing power to the blockchain to become nodes) or Proof-of-Stake (miners commit cryptocurrency to the blockchain to become nodes).
      Finalise:
      Once the transaction data has been written onto the distributed ledger of the blockchain, the consensus mechanism verifies that the assets transferred by the first party have been received and unfreezes them for the receiving party. This marks the completion of the smart contract, which is then closed and recorded. It cannot be modified or tampered with – a concept called ‘finality’.
      Can smart contracts be destroyed?
      The Ethereum blockchain does allow a provision to execute the self-destruct function, should anything go wrong. For developers, this is a double-bladed sword as this function enables the transfer of funds labeling the situation as an emergency. This provides a channel for cyber attackers to illegitimately get funds transferred as well. This vulnerability adds complexity to the coding of a smart contract.
      However, when such flaws are discovered, developers also add upgraded protocols to put reinforced security measures in place. Once the gaps are bridged, a fresh contract is created using the upgraded protocols.
      Check out our in-depth Market Coverage, Business News & get real-time Stock Market Updates on CNBC-TV18. Also, Watch our channels CNBC-TV18, CNBC Awaaz and CNBC Bajar Live on-the-go!
      arrow down

        Most Read

        Market Movers

        View All
        CompanyPriceChng%Chng