Ethereum – introduction to smart contract development and environment construction

Table of contents

1. The concept of smart contract

2. Advantages of smart contracts

 3. Smart contract development

3.1 Blockchain that supports smart contracts

3.2 Ethereum smart contract development tools

3.3 Ethereum Smart Contract Development Language

4. Build smart contract development environment

4.1 Preparations

4.2 Node and NPM

4.3 Truffle framework

4.4 Ganache

4.5 Metamask

4.6 VS code and Solidity plugin


1. The concept of smart contract

A smart contract is a computer protocol designed to disseminate, verify or enforce contracts in an informational manner. Smart contracts allow for trusted transactions without third parties, which are traceable and irreversible. The concept of smart contracts was first proposed by Nick Szabo in 1995.

The purpose of smart contracts is to provide a method of security superior to traditional contracts and to reduce other transaction costs associated with contracts.

2. Advantages of smart contracts

Smart contracts have some significant advantages over traditional contracts:

  • no middleman needed
  • low cost
  • code is the rule
  • There are multiple backups in the blockchain network, no need to worry about loss
  • avoid human error
  • Agreements can be fulfilled without trust
  • Anonymous Performance Agreement

 3. Smart contract development

3.1 Blockchain that supports smart contracts

        

While Ethereum is the most popular blockchain platform that supports smart contracts, it is not the only one that supports them.

Hyperledger  is an open source project initiated by the Linux Foundation in 2015 to promote blockchain digital technology and transaction verification. By creating an open standard for distributed ledgers, virtual and digital value exchanges, such as asset contracts, energy transactions, and marriage certificates, can be tracked and traded safely, efficiently and at low cost.

In addition, there are many other blockchain platforms that support smart contracts, you can refer to relevant information.

3.2 Ethereum smart contract development tools

Typically, tools are required to develop smart contracts:

  • Mist  - Ethereum node/wallet.
  • Truffle framework  – a popular Ethereum development framework with built-in smart contract compilation, linking, deployment and other functions.
  • Metamask  - Ethereum node/wallet as a Chrome plugin.
  • Remix  - Remix is ​​a web browser-based smart contract development environment (IDE).

3.3 Ethereum Smart Contract Development Language

At present, the main smart contract development language is  Solidity language , which is a static high-level language for developing Ethereum smart contracts, and its syntax is similar to JavaScript.

There are other smart contract development languages:

etc.

4. Build smart contract development environment

4.1 Preparations

In order to build and develop smart contracts or dApps, we need to install the following modules:

  • Node and NPM
  • Truffle framework
  • Ganache
  • Metamask
  • VScode and Solidity plugin

4.2 Node and NPM

The Truffle framework depends on Node and needs to be installed using npm.

First, you need to install node, and npm will install it at the same time, download node , and install according to the prompts.

After installation, you can verify the node version:

$ node -v

4.3 Truffle framework

The Truffle framework is a popular Ethereum development framework with built-in smart contract compilation, linking, deployment and other functions.

Install the Truffle framework using npm:

$ npm install -g truffle

Verify truffle installation:

$  truffle --version
Truffle v5.0.35 - a development framework for Ethereum
...

4.4 Ganache

Testing and deploying Dapps or smart contracts on the actual Ethereum network requires Gas consumption. Ganache can create a blockchain network locally to test our programs.

Ganache can be downloaded from the Truffle Framework website for installation. It will create a local blockchain network and assign us 10 external accounts with 100 fake ether each.

4.5 Metamask

Metamask is an Ethereum node/wallet in the form of a Chrome plugin.

We can use Metamask to connect to the local blockchain network or the actual Ethereum network and interact with our smart contracts.

To install Metamask, search for the Metamask Chrome extension in the Google Chrome web store and install it. Once installed, make sure to turn on the Enable button. Once installed, you'll see a fox icon in the upper right corner of your Chrome browser.

4.6 VS code and Solidity plugin

It is recommended to use the vs code editor to write solidity code. vs code can install the solidity plug-in to support syntax highlighting.

Guess you like

Origin blog.csdn.net/qq_62294245/article/details/125457982
Recommended