Module IV - Part I
Module IV - Part I
The idea of smart contract templates is to build standard templates that provide a
framework to support legal agreements for financial instruments.
DSLs have a small set of features that are sufficient and optimized for the domain.
DSLs are usually not used to build general purpose large application programs.
The focus is on developing high-level DSLs that can be used to program a smart
contract in a user-friendly graphical user interface, thus allowing a non-programmer
domain expert (for example, a lawyer) to design smart contracts.
Oracles
Important component of the smart contract ecosystem.
The limitation with smart contracts is that they cannot access external data, which
might be required to control the execution of the business logic;
for example, the stock price of a security product that is required by the contract to
release the dividend payments.
Oracles can be used to provide external data to smart contracts.
An Oracle is an interface that delivers data from an external source to smart
contracts.
Depending on the industry and requirements, Oracles can deliver different types of
data ranging from weather reports, real-world news, and corporate actions to data
coming from Internet of Things (IoT) devices.
A generic model of an Oracle and smart contract ecosystem
Oracles are trusted entities that use a secure channel to transfer data to a smart
contract.
Oracles are also capable of digitally signing the data proving that the source of the
data is authentic.
Smart contracts can subscribe to the Oracles, and the smart contracts can either
pull the data or Oracles can push the data to the smart contracts.
It is also necessary that Oracles should not be able to manipulate the data they
provide and must be able to provide authentic data.
.
Decentralized Oracles
These types of Oracles can be built based on some distributed mechanism.
Oracles can find themselves source data from another blockchain, which is driven
by distributed consensus, thus ensuring the authenticity of data.
For example, one institution running their private blockchain can publish their data
feed via an Oracle that can then be consumed by other blockchains.
Hardware Oracles
Real-world data from physical devices is required.
Can be used in telemetry and IoT.
Hardware devices are required to be tamper proof.
This can be achieved by using cryptographic services.
Smart Oracles
Smart Oracles are entities just like Oracles, but with the added capability of contract
code execution.
Smart Oracles proposed by Codius run using Google Native Client, which is a
sandboxed environment for running untrusted x86 native code.
Software Oracles
Eg. single value can be the price of a financial instrument, and it can be risky to rely
upon only one feed.
Multiple data providers can be used where all of these feeds are inspected, and
finally, the price value that is reported by most of the feeds can be picked up.
Crowd wisdom driven oracles
Useful when a single source of information is not trusted.
Multiple public sources are used to deduce the most appropriate data eventually
A political event or a sporting event where members of the public know the results
and can provide the required data
Similarly, this data can be sourced from multiple different news websites
This data can then be aggregated, and if a sufficiently high number of the same
information is received from multiple sources, then there is an increased likelihood
that the data is correct and can be trusted.
Smart oracles
They can execute contract code.
Deploying smart contracts on a blockchain
Ethereum is an example of a blockchain platform that natively supports the
development and deployment of smart contracts.
Smart contracts on Ethereum blockchain are usually part of a broader application
such as Decentralized Autonomous organization (DAOs).
Bitcoin scripting language, though limited, can be used to construct basic smart
contracts.
For example, you can implement conditions such as "Pay party X, N amount of
bitcoins after 3 months".
Various other blockchain platforms support smart contracts such as Monax, Lisk,
Counterparty, Stellar, Hyperledger fabric, corda, and Axoni core.
Smart contracts can be developed in various languages.
The critical requirement, for smart contract is determinism, which is very important
because it is vital that regardless of where the smart contract code executes, it
produces the same result every time and everywhere.
Various languages have been developed to build smart contracts such as Solidity,
which runs on Ethereum Virtual Machine (EVM).
There are platforms which already support mainstream languages for smart contract
development.
Hyperledger fabric supports Golang, Java, and JavaScript for smart contract
development.
Decentralized Organizations
DOs are software programs that run on a blockchain and are based on the idea of
actual organizations with people and protocols.
Once a DO is added to the blockchain in the form of a smart contract or a set of
smart contracts, it becomes decentralized and parties interact with each other
based on the code defined within the DO software.
Decentralized Autonomous Organizations
Just like DOs, a Decentralized Autonomous Organization (DAO) is also a computer
program that runs atop a blockchain and embedded within it are governance and
business logic rules.
DAO and DO are fundamentally the same thing: The main difference, is that DAOs
are autonomous, which means that they are fully automated and contain
artificially-intelligent logic.
DOs, on the other hand, lack this feature and rely on human input to execute
business logic.
The Ethereum blockchain led the way with the initial introduction of DAOs.
In a DAO, the code is considered the governing entity rather than people or paper
contracts.
However, a human curator maintains this code and acts as a proposal evaluator for
the community.
DAOs are capable of hiring external contractors if enough input is received from the
token holders (participants).
Currently, DAOs do not have any legal status, even though they may contain some
intelligent code that enforces certain protocols and conditions.
Decentralized Applications (DApps)
DApps, are software programs that can run on their respective blockchains, use an
existing established blockchain, or use only the protocols of an existing blockchain.
These are called Type I, Type II, and Type III DApps.
i) The DApp should be fully open source and autonomous, and no single entity
should be in control of a majority of its tokens. All changes to the application must
be consensus-driven based on the feedback given by the community.
ii) Data and records of operations of the application must be cryptographically
secured and stored on a public, decentralized blockchain to avoid any central points
of failure.
iii) A cryptographic token must be used by the application to provide access and
rewards to those who contribute value to the applications, for example, miners in
Bitcoin.
Whenever the front end needs the user to sign a transaction, it calls on Metamask.
So metamask plays the role of the signer.
Metamask will allow us to connect the blockchain with our personal account and
interact with the smart contract.