The development of blockchain technology to the present is generally considered to have gone through three stages, namely the first stage represented by Bitcoin, the second stage represented by Ethereum and the third stage represented by EOS.
1. Smart Contract
Starting from Ethereum, smart contracts have entered the stage of history, and then various blockchains that can execute smart contracts have appeared. The ability of the smart contract TX (called INT Contract). Furthermore, NeoContract of Xiaoyi starts from the convenience of development and supports multiple languages, such as C#, C++, etc. Others, such as Asch, split different contracts called token systems or arbitration contracts. Wait, and so on.
The location of Ethereum's smart contracts in the blockchain is as follows:
In fact, that is to say, smart contracts have already occupied an important place in the blockchain.
To understand smart contracts well, it is actually necessary to understand virtual machines, such as EVM of Ethereum, WASM of EOS, etc. These are similar to the JAVA virtual machine (this one is not appropriate, but easy to understand, in fact the former is much simpler) to run some code, whether it is interpreted or compiled, or both.
From the initial execution of some simple instructions to the execution of binary data, the virtual machine gradually matures. Along with it, smart contracts are becoming more and more powerful and easy to use.
2. Examples of smart contracts
1. Bitcoin script (smart contract-like)
Why is it called a smart contract? In fact, Bitcoin does not have smart contracts, only scripts. It just uses some simple instructions to complete specific functions. The following is the description of a Bitcoin script:
2. Ethereum smart contract
Ethereum's smart contracts are closer to popular programming languages, and it also has its own IDE, browser-solidity, which can easily write and debug smart contracts:
contract TestStore {
uint sData;
function setData(uint d) {
sData = d;
}
funcTIon getData() constant returns (uint) {
return sData;
}
}
This contract just stores and reads a piece of data, but it's a huge step forward from Bitcoin's script.
3. EOS smart contract
First look at an introductory smart contract hello world.
class hello :public eosio::contract
{
public:using contract::contract;
/// @abi acTIon
void helloworld( account_name user )
{
print("Hello world, ", name{user});
}
};
EOSIO_ABI( hello, (helloworld) )
You will find that EOS smart contracts are completely consistent with mainstream development languages.
3. Compilation of smart contracts
The compilation of smart contracts has different processing methods in different periods, and it is believed that there will be greater progress in the future.
In the early days of Bitcoin, the script was just split into strings, and there was nothing unique, let alone the compilation step. When it came to Ethereum, an independent programming language Solidity and a compiler appeared. Only after compiling with the compiler can it run in the EVM virtual machine.
When it comes to EOS, it is even more powerful to use CLANG+LLVM to generate Webassembly bytecode format. This means that very powerful mainstream compilers and common compilation methods can be used. This enables the EOS compiler to compile more secure and robust executable smart contracts.
4. Execution of smart contracts
Bitcoin's script execution is very simple, just call the function to analyze the string, parse the corresponding instructions according to different tags, and then verify and execute the function according to the corresponding instructions, so that the script is finally achieved. purpose of operation.
To execute a smart contract in Ethereum, you need to use the SOLC smart contract compiler to compile the code into EVM bytecode, and then send the EVM bytecode to the Ethereum network through Geth's RPC interface to verify the execution.
The smart contract of EOS needs to convert .wast to .wasm file through JIT, and assist an abi file. The two work together to deploy the smart contract on the virtual machine and execute it by the virtual machine.
5. Oracle
The oracle is the interface between the blockchain and the natural world, and it is currently a direction of the development of blockchain technology. For smart contracts, the oracle is the input parameter of the smart contract. And everyone knows that smart contracts cannot be separated from the input of parameters. The parameters directly affect the final output of the smart contract.
For example, predicting the result of the World Cup depends on the data input of key nodes. If someone maliciously enters the wrong result, the smart contract will definitely output the wrong conclusion based on the wrong result.
Therefore, the dependence of the oracle on the input parameters is strongly correlated. Oracles can be divided into the following types:
1. The software provides data oracles
This kind of oracle is well understood. Similar to the above example, the input parameters need to be obtained by some websites or related service providers.
2. An oracle with data provided by hardware
Mainly in the Internet of Things industry, a large amount of data can be collected and sent from hardware collectors or related sensors.
3. Trusted Consensus Oracle
The main purpose is to solve the reliability problem of the input parameters, without using a single data source, such as collecting data from multiple data points, and achieving the final parameter collection input according to the consensus principle.
Oracles are now starting to show up on various blockchains one after another. There are some simple oracle machines inside Ethereum, and then a third-party Ethereum's Oraclize appeared, which provides a powerful ability to interact with the outside world. The hybrid oracle (HydraDAO) of the domestic ONT and the Oracle of the quantum chain (QTUM) have enhanced the DataFeeds mechanism, which is more flexible and convenient.
There are also smart oracles that can automatically and flexibly implement smart contracts under different conditions.
6. Summary
Smart contracts and oracles complement each other, and will definitely grow in the development of blockchain technology, ultimately realizing the natural and efficient flow of data in the natural world and the blockchain world.
Battery Management Systems For Lithium Cells
Shenzhen Zhifu New Energy Co., Ltd. , https://www.sunbeambattery.com