408
X. Liu et al.
8.3.3 Smart Contracts
The second generation of blockchains such as Ethereum [9] uses smart contracts.
Smart contracts are executable computer code stored on a blockchain. Similar
to transactions, smart contract code is transparent and can be examined by all
participants of the blockchain. Smart contracts are accessed via their addresses and
users can activate them by sending them transactions. In an Ethereum blockchain,
smart contracts run on every node of the blockchain which has a virtual machine
running. The smart contracts execute under the virtual machine.
To a large extent, smart contracts are very similar to stored procedures in database
management systems. Functions in smart contracts are defined based on business
rules. Participants can initiate transactions to call functions in smart contracts along
with the required data. Smart contracts are deterministic and the same input to a
smart contract always generates the same output. Smart contracts can call each other
as well. The code of a smart contract can be examined by participants so that they
can predict the outcome before they commit the contract. The outcomes of executing
smart contracts can be verified by participants too. Smart contracts help prevent
possible contract disputes.
8.3.4 Consensus Algorithms
When designing or adopting blockchains, several factors need to be considered.
The first factor to consider is who can access the blockchain. This depends on
whether the blockchain will be openly accessible by the public or not. If it is, public
blockchains must be used. The decision also affects the selection of consensus
mechanisms. A private blockchain needs to be adopted if only specific participants
can access the blockchain. Private blockchains can employ special consensus
algorithms so that time-consuming minings are not required.
As stated previously, a blockchain consists of multiple identical ledgers stored in
distributed computers. A blockchain may not be controlled by any central authority.
It is therefore obvious that malicious users will be very much attempted to take
advantage of the blockchain. This situation of the blockchain is very similar to
the famous Byzantine Generals’ Problem. From this sense, blockchains require
Byzantine Fault Tolerance (BFT). Without BFT, bad users will be able to break the
blockchains by sending malicious transactions. If damages do occur, they will not
be repaired because no central authority is available to carry out corrective actions.
For this reason, consensus algorithms are used to provide BFT.
So far, large numbers of consensus algorithms have been developed for
blockchains. With consensus algorithms, mutually distrustful participants can work
together. Each of the consensus algorithms has its own strengths and weaknesses
and is suited for specific applications. Although the number of proposed consensus
X. Liu et al.
8.3.3 Smart Contracts
The second generation of blockchains such as Ethereum [9] uses smart contracts.
Smart contracts are executable computer code stored on a blockchain. Similar
to transactions, smart contract code is transparent and can be examined by all
participants of the blockchain. Smart contracts are accessed via their addresses and
users can activate them by sending them transactions. In an Ethereum blockchain,
smart contracts run on every node of the blockchain which has a virtual machine
running. The smart contracts execute under the virtual machine.
To a large extent, smart contracts are very similar to stored procedures in database
management systems. Functions in smart contracts are defined based on business
rules. Participants can initiate transactions to call functions in smart contracts along
with the required data. Smart contracts are deterministic and the same input to a
smart contract always generates the same output. Smart contracts can call each other
as well. The code of a smart contract can be examined by participants so that they
can predict the outcome before they commit the contract. The outcomes of executing
smart contracts can be verified by participants too. Smart contracts help prevent
possible contract disputes.
8.3.4 Consensus Algorithms
When designing or adopting blockchains, several factors need to be considered.
The first factor to consider is who can access the blockchain. This depends on
whether the blockchain will be openly accessible by the public or not. If it is, public
blockchains must be used. The decision also affects the selection of consensus
mechanisms. A private blockchain needs to be adopted if only specific participants
can access the blockchain. Private blockchains can employ special consensus
algorithms so that time-consuming minings are not required.
As stated previously, a blockchain consists of multiple identical ledgers stored in
distributed computers. A blockchain may not be controlled by any central authority.
It is therefore obvious that malicious users will be very much attempted to take
advantage of the blockchain. This situation of the blockchain is very similar to
the famous Byzantine Generals’ Problem. From this sense, blockchains require
Byzantine Fault Tolerance (BFT). Without BFT, bad users will be able to break the
blockchains by sending malicious transactions. If damages do occur, they will not
be repaired because no central authority is available to carry out corrective actions.
For this reason, consensus algorithms are used to provide BFT.
So far, large numbers of consensus algorithms have been developed for
blockchains. With consensus algorithms, mutually distrustful participants can work
together. Each of the consensus algorithms has its own strengths and weaknesses
and is suited for specific applications. Although the number of proposed consensus
