Smart Contract: Introduction to contractware

A Smart Contract (SC) is a program stored on a Blockchain that executes when predetermined conditions are met. It is a collection of code (its functions) and data (its state) that resides at a specific address on the Blockchain.

SCs operate by following simple “if/when…then…” statements that are written into the Blockchain code. A network of computers executes actions when predetermined conditions are met and verified.

  • Conditions: Within an SC, there can be as many stipulations as necessary to satisfy the participants that the task will be completed successfully. To establish conditions, participants must determine how transactions and their data are represented on the Blockchain, agree on the “if/when…then…” rules governing those transactions.
  • Actions: These actions could include releasing funds to the appropriate parties, registering a vehicle, sending notifications, or issuing a ticket. The Blockchain is updated when the transaction is completed. This means that the transaction cannot be modified, and only the parties that have been granted permission can view the results

Although it may seem complicated at first, the concept of SCs has been around for several decades (1997), but at that time it was impossible to make it a reality with the existing technology infrastructure. In order for SCs to be implemented, programmable transactions and a digitally native financial system that recognizes them must be in place.  The growing interest in this technology can largely be attributed to the implementation of SCs on Blockchain. Until the advent of Blockchain, autonomous execution of contracts was not possible, because the parties used to share separate databases. With SCs, Blockchain becomes more than an immutable record-keeping system, transforming into a full-fledged transaction platform. They can be used to automate the execution of an agreement, so that all participants can be immediately certain of the outcome, with no intermediary involved and no time wasted.

There are two different types of smart contracts:

  • Installed. They install the business logic in the network validators before the network is started.
  • On-chain. They implement the business logic as a transaction sent to the blockchain and then called by subsequent transactions. In this type of contracts, they are stored inside the ledger so they inherit the properties of immutability and avoids single points of failure

The main challenges for this technology are to improve the semantics of smart contracts, the integration with the procedures that are given and want to be regulated with SC; in addition to its range of applicability, due to the fact that it is a young technology, its legality and its flexibility.

 

Smart Contract Processing

In general, the smart contract layer works closely with the consensus layer. Specifically, the smart contract layer receives a proposal from the consensus layer. This proposal (Inputs) specifies which contract to execute (Contract ID), the details of the transaction, including the identity and credentials of the entity requesting the contract execution (Transaction Request), and any transaction dependencies.

The smart contract layer (via the contract interpreter) uses the current state of the ledger and the input from the consensus layer to validate the transaction. That is, the contract interpreter, the block in the middle of the figure, is loaded with the current ledger state and the smart contract code. When the contract interpreter receives a request, it immediately verifies and then rejects any invalid request.

Smart Contract Business Logic

While processing the transaction, the smart contract layer uses the identity services layer to authenticate and authorize the entity requesting to execute the smart contract. This ensures two things: that the entity is known in the blockchain network and that the entity has the appropriate access to execute the smart contract. Identity can be provided through several methods: simple key-based identities, identities and credentials managed through the ledger, anonymous credentials, or identity services managed from an external certificate authority.

After processing the transaction, the smart contract layer returns whether the transaction was accepted or rejected (Outputs). If the transaction was accepted, the smart contract layer also returns a correctness certification, a status delta, and any optional ordering suggestions required for consensus services. The status delta includes the change sets and any side effects that should take place when the peers successfully commit the transaction. The output packet is sent to the consensus service for final commitment to the blockchain.

 

Leave a Comment

Your email address will not be published. Required fields are marked *