Understanding Smart Contracts

Source: Internet
Author: User
Tags knowledge base sublime text

"Hui Xin Yun" for everyone regularly updated articles, "Hui new cloud" It hardware and software projects business Platform 0x00 Preface

Understanding smart contracts is critical to understanding blockchain technology. Let's take a look at what is a smart contract first.

The smart contract is the 1990s era of the concept proposed by Nick Saab, almost the same age as the Internet. Due to the lack of a credible execution environment, smart contracts have not been applied to the real estate industry, since the birth of Bitcoin, people realize that the underlying technology blockchain can provide a credible execution environment for smart contracts, Ethereum first saw the link between blockchain and smart contract, published the White paper " Ethereum: The next generation of smart contracts and application platforms for central applications, and has been working to make Ethereum the best smart contract platform, so bitcoin leads the blockchain, Ethereum Resurrection Smart Contract. [1]

In other words, the concept of smart contracts is not born with blockchain technology. Blockchain technology naturally brings a unique application premise to intelligent contracts. If blockchain is used, Bitcoin and Ethereum are the biggest applications.

Map from: ©guia do bitcoin/tudo que vocêprecisa saber sobre o Ethereum hard Fork que aconteceráamanhã/guiadobitcoin.com . BR

To understand what a smart contract concept is, let's look at how to understand it next. 0x01 Smart Contract

A smart Contract program is not just a computer program that can be executed automatically: it is itself a system participant. It responds to the information it receives, it can receive and store value, and it can send out information and value.

This program is like a person who can be trusted to temporarily take care of assets and always follow the rules in advance.

The following diagram is a smart contract model: A piece of code (a smart contract) that is deployed on a shared, duplicated ledger that can maintain its own state, control its assets, and respond to external information or assets received.

Smart Contract Model: It is a computer program running on a replicable, shared ledger that can process information, receive, store, and send value.

Simply put, a smart contract is a digital version of a traditional contract. They are computer programs that run on a blockchain database and can be executed on their own when the conditions written in their source code are met. Once a smart contract is written, it can be trusted by the user and the terms of the contract cannot be changed, so the contract is immutable.

How does the real world apply smart contracts? The developer will write code for the smart contract. Smart contracts can be used for trading and/or for any exchange between two parties/multiparty. The code contains some conditions that will trigger automatic execution of the contract. Once the encoding is complete, the smart contracts are uploaded to the blockchain network, i.e. they are sent to all devices connected to the network. Once the data is uploaded to all devices, the user can reach agreement with the results of executing the program code. The database is then updated to record the execution of the contract and to oversee the terms of the contract to check compliance. [2] 0x02 solidity

Solidity is a high-level language that is syntactically similar to JavaScript and is designed to generate Ethereum virtual machine (Ethereum MACHINE,EVM) code in a compiled fashion.

Its syntax is close to Javascript and is an object-oriented language. But as a real way to run on the network to the central contract, it has a lot of different, the following list some:

The Ethereum bottom is based on accounts, not UTXO, so there is a special address type. The code for locating the user, locating the contract, and locating the contract (the contract itself is also an account).

Because the language inline framework supports payment, some keywords, such as payable, can be used to support payments directly at the language level.

Storage is using blockchain on the network, each state of the data can be stored permanently, so you need to determine whether the variable uses memory or blockchain.

The operating environment is on a centralized network, and the way in which calls to contracts or functions are performed are compared. Because a simple function call turned out to be code execution in a node on a network.

The last very big difference is its anomaly mechanism, in the event of an exception, all executions will be withdrawn, mainly to ensure the atomicity of the contract execution to avoid inconsistent data in the intermediate state. [3] 0x03 dapp

The Dapp application is a service that enables direct interaction between users and suppliers. Ethereum de-centralized applications typically interact with users through Html/javascript Web applications, using Javascript APIs to communicate with blockchain. A de-centralized application typically has its own set of related contracts on the blockchain, which encodes the business logic, allowing persistent storage to require a state of strict consensus.

Dapp and apps are the corresponding. We are already familiar with the app and we are currently using various types of apps primarily on IOS and Android platforms. Usually an app from the design, development, testing, online and other processes are done by a centralized organization, the application is based on the C/S architecture, which S represents the Server, is also a centralized structure. Dapp does not entirely mean that its development is to be centralized, but that its operation is to be centralized.

At present the most successful Dapp is cryptokitties, that is, the cat game. The online game once caused a serious blockage of the Ethereum network.

According to the state of the Dapps website, there are currently 977 Dapp based on Ethereum. Interested readers may wish to search and see. 0x04 Practice

If you want to learn about smart contract programming, here are some things to note:

Before you learn a smart contract, you need to understand the blockchain, Bitcoin, and ethereum knowledge.

Read the ERC20 protocol carefully.

Learn JavaScript, solidity programming languages.

Familiar with peripheral tools, such as truffle, Remix, metamask and so on.

Set development goals and implement some small applications.

Read the well-known ERC20 Blockchain project code.

For example, in the fifth step, you can issue tokens on your own in the Ethereum test network or on a formal network, and you can implement the first DAPP based on the open source Pet shop. 0x05 Related Resources 5.1 Terminal

Mist

Metamask

Myetherwallet 5.2 IDE

Remix-solidity IDE

If you use Sublime Text for solidity programming, the following plugins are recommended:

Solium Gutter

Ethereum

Ethereumsoliditysnippets

If you are using Atom for solidity programming, the following plugins are recommended:

Linter-solidity

Autocomplete-solidity

Linter-solium 5.3 Frameworks/tools

JSON RPC API

Truffle development Framework

Ethereum JavaScript API

Solidity GitHub

Open-zeppelin

Truffle-artifactor 5.4 Docs

Ethereum official website

Ethereum GitHub

Solidity official documents

Embark ' s documentation

"Solidity Smart contract Programming Guide"

Ethereum Smart Contract Quick Start

The Ethereum Wiki

Dapp Developer Resources

Ethfans Knowledge Base

How to write a smart contract

Cace on Blockchain and Ethereum 5.5 Forum

Web3-js Forum

Ethereum for Web Developers

Ethereum Chinese Technology Community

Taipei Ethereum Community expert linked fields

Blockchain Technology Chinese community

DeveloperWorks Community

Story Backlog)

Gitter Chat 0x06 Summary

This article describes the smart contract, a smart contract program is not just a computer program that can be executed automatically: it is itself a system participant. It responds to the information it receives, it can receive and store value, and it can send out information and value. Then it explains the programming language solidity used in the intelligent contract, then introduces the Dapp, then gives the steps of learning intelligent programming, finally gives the related resources, hoping to help the readers.

In the future there will be more dapp into our lives, if the reader is a developer, may wish to find a scene to achieve a dapp. 0x07 Reference

[1] GitHub (2016-07-07). Smart contracts. Retrieved from https://github.com/EthFans/wiki/wiki/Smart contract.

[2] Know (2017-07-05). Why use blockchain technology to implement smart contracts. Retrieved from https://www.zhihu.com/question/43404157/answer/193952393.

[3] Pinterest (2016-12-18). Solidity language Introduction. Retrieved from https://www.jianshu.com/p/b9f78f9b4c3e.

Learn blockchain, single item million + Not dream:

Blockchain Product Manager (click to settle), the ability is not enough to mix a face ripe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.