Blockchain Frameworks — Part 2: Smart Contracts
In this and the next articles, I will make an explanation of the Blockchain technology and its most known frameworks
INDEX:
- Part 1: Introduction
- Part 2: Smart Contracts
- Part 3: Blockchain Types
- Part 4: Ethereum
- Part 5: Hyperledger
- Part 6: IOTA
- Part 7: Quorum
- Part 8: Extra 1; Hedera Hashgraph
- Part 8: Extra 2; Libra
Part 2: Smart Contracts:
The initial use of the Blockchain technology was to make peer-to-peer monetary transactions without the need of a trusted third party.
Bitcoin is the best example.
Later, the Blockchain technology started growing and began to support the execution of smart contracts during transactions, adding much more functionality to Blockchain.
A Smart Contract is a program or a piece of code that runs in the Blockchain, and it is executed when a transaction occurs and its correct execution is enforced by the consensus algorithm of the network.
A contract can encode any set of rules represented in its programming language — for instance, a contract can execute transfers when certain events happen (e.g. payment of security deposits in an escrow system).
Accordingly, smart contracts can implement a wide range of applications, including financial instruments (e.g., sub-currencies, financial derivatives, savings wallets, wills) and self-enforcing or autonomous governance applications.
Example:
In the previous example, we can see how two organizations, ORG1
and ORG2
have defined a car
smart contract to query
, transfer
and update
cars.
Applications from these organizations invoke this smart contract to perform an agreed step in a business process, for example to transfer ownership of a specific car from ORG1
to ORG2
.
Ledger:
In a simple way, a Blockchain registers in an immutable way all the transactions that take place in a distributed ledger. Every node in the Blockchain network has an updated copy of that ledger.
A smart contract programmatically accesses two distinct pieces of the ledger:
- A blockchain, which immutably records the history of all transactions,
- A world state that holds a cache of the current value of these states, as it’s the current value of an object that is usually required.
Normally, Smart Contracts are mainly used to add, remove, obtain or update states in the world state as well as may query the immutable blockchain record of transaction.
Any action (either adding a new element or deleting an existing one from the world state) is in the Blockchain immutable record.
Smart Contracts Languages:
To develop a Smart Contract, depending on which Blockchain framework you are using, you will must code it in a specific programming language (although, currently multiples frameworks support several programming languages).
Some examples are:
- Ethereum: Solidity
- Hyperledger Fabric: Supports Go, NodeJS and Java
- Hedera Hashgraph: Solidity
- NEO: C#
- EOS: C++