Introduction to Blockchain | Advanced Understanding of Smart Contracts-Implementation

On July 30, 2015, the first block of Ethereum was dug out, and Ethereum officially entered the stage of history. As a result, smart contracts have also become popular. We can see from Google Trends that smart contracts are related to Ethereum.

The concept of smart contracts was introduced by Nick Saab in 1995. At that time, there was no Bitcoin, no blockchain, and no Ethereum.

Nowadays, the mainstream cognition is binding smart contracts with Ethereum (or Ethereum-like projects). Ethereum is a smart contract platform. Anyone can publish code that defines certain contract attributes on Ethereum and entrust it to the Ethereum network to run.

Just as Jack Ma developed the Taobao platform, people can open online stores on Taobao. Running an online store does not require the store to deploy its own servers. The back-end of the online store runs entirely on Taobao.

At present, smart contract instances with high influence are basically running on Ethereum. The most widely used ones are token issuance, DeFi, and decentralized gambling.

Regarding the application direction of smart contracts, the mainstream information now has more consensus on smart contracts to transform traditional contracts into smart contracts. Traditional contracts use social customs and laws to define the rights and obligations of participants. Customs and laws are the source of binding force behind contracts. Smart contract transformation is expected to take the source of binding force in the code.

This is why smart contracts are tied together by Ethereum and Ethereum-like projects. Because Ethereum provides a binding code execution platform. Ethereum is designed as a world computer that allows programs to run independently of specific centralized servers.

Bitcoin enthusiasts are very dissatisfied with the brilliant performance of Ethereum on smart contracts, and they also think of a lot of ways for the Bitcoin network to undertake smart contract business.

The Bitcoin system has a built-in script engine to complete the programmability of the ledger. Ethereum uses a virtual machine. The latter is Turing-complete and can be used to run very complex programs. Coupled with Bitcoin's UTXO design, Ethereum is an account design. The former can only design stateless contracts. This means that the contract code on Bitcoin cannot use its intermediate state generated by itself. Bitcoin script programs are one-time, only valid for this transaction, and cannot be referenced by other transactions. Bitcoin's script code can't read data either, you can't write a program to order a certain transaction of Bitcoin to get specific parameters. There are very few exceptions, such as the block CSV instruction, which allows Bitcoin scripts to rely on block height to respond. Correspondingly, Ethereum's virtual machine does not have these obstacles.

However, the Bitcoin network can still accept specific smart contracts. The P2SH transaction format allows code to be embedded in scripts and can be used to implement specific application scenarios. Core developers working on Merkel's Abstract Syntax Tree (MAST) are expected to build Bitcoin scripts into more complex code.

BCH has implemented opcodes such as OP_CHECKSIGVERIFY. The script can verify external data (Oracle) and can be used to build decentralized arbitrated asset transactions. For example, local.bitcoin.com released by Bitcoin.com is a decentralized asset trading platform. This opcode can also be used to build decentralized betting.

But whether it is using Ethereum's smart contract platform or the Bitcoin script engine to implement smart contracts, it is the idea of ​​transforming traditional contract smart contracts. The idea is obviously to have a hammer in your hand, to see everything is a nail. Now that there is a smart contract platform, it is like having a hammer. You have to hammer all the traditional contracts with this hammer. In fact, the traditional contract does not need to be transformed in most cases.

This idea is a dwarf of smart contracts.

As described in the previous article "Preliminarily Clear Understanding of Smart Contracts", Bitcoin mining is a perfect smart contract. Mining is a brand-new creation of a business paradigm, an intelligent business paradigm.

This is an idea for the development of smart contracts, creating a new business paradigm.

Any chain, whether it is PoW or PoS, is actually a similar business paradigm case. In the PoW chain, miners deliver proof of work, help users package transactions, and issue Coinbase rewards. In the PoS chain, nodes deliver proof of coin age, help users verify transactions, and issue coin rewards.

In a decentralized exchange, the two parties involved in the transaction are point-to-point, and both parties control their own assets before closing. During the transaction, there is no third party involvement. The decentralized exchange is also a self-operating, open and transparent smart contract that does not require authorization.

Similar to Openbazaar, it is a decentralized Taobao, and participants are also self-running commercial platforms that do not require registration. It should be noted that Openbazaar does not record all commercial transactions.

Perhaps, when designing a blockchain project, we first want to understand how to design a smart contract with self-consistent business logic.

When Nick Saab proposed the concept of smart contracts, Bitcoin and Ethereum were not born. An automated program that limits smart contracts to a certain smart contract platform is a dwarfing of the concept of smart contracts. Return to the original intention of smart contracts, reduce business costs, reduce default risks, and expand business scope.

Author: Huang Shiliang

Welcome to WeChat public account: Lightning HSL, H13116885

Welcome to BTM: bm1qefc720au672awrgazgw5c3kx7etr5kejju02p7