Start learning blockchain technology with an overview of Ethereum Solidity and contract examples!

This article is participating in the "Golden Stone Project. Share the 60,000 cash prize" 

Introduction to Solidity language

Solidity is a statically typed programming language for developing smart contracts that run on Ethereum. Solidity is compiled into bytecode that runs on the Ethereum Virtual Machine (EVM). The Ethereum Virtual Machine (EVM) is the running environment for smart contracts. With solidity, developers can write applications that run on Ethereum. Of course, there is more than one smart contract on the market, and many chains have their own smart contracts, which are basically derived from solidity. Such as TRON, sCrypt, Binance Chain, etc. - Solidity is a language specifically designed to run on the Ethereum Virtual Machine.

b3fcc3e501378f5cc3056addd55144f.jpg

Introduction to Ethereum

Ethereum is an open source public blockchain platform with smart contract functionality. The Ethereum platform provides various modules for users to build applications. If building an application is like building a house, then Ethereum provides modules such as walls, roofs, and floors. Users only need to build the house like building blocks. Therefore, The cost and speed of building applications on Ethereum have greatly improved. Ethereum uses a Turing-complete Ethereum Virtual Machine language (Ethereum Virtual Machinecode) to build applications

Ethereum layered

The Ethereum system can be roughly divided into three layers: application layer, blockchain core layer, and basic bottom layer.

bf100bed08b04b7b87ff7ef7281db1f.jpg- The Ethereum client includes the core layer and the basic bottom layer of the blockchain. Different Ethereum clients form an Ethereum network through point-to-point communication (p2p, peer to peer) communication network. -The application layer is the part where users participate in development. Applications running on the blockchain network are also called decentralized applications (DApp). When we first come into contact with the blockchain, we can start from this layer and learn about smart contracts. , and then use web3.js to interact with the front end to implement a simple DAPP.

  • Note: There are a lot of other things on the Internet, so I won’t go into details one by one.

contract

Before we write a contract, we need to master some basic knowledge: the suffix of the contract file .sol. A solidity file can contain any number of contract definitions, import instructions, and pragma instructions. - We may be curious why we get a warning when we delete the first line of commented out code. It is considered a license. The SPDX license list is an integral part of the SPDX specification. You can take a look at this article: Smart Contract Basics - -Grammar basics -Code examples and comments solidity pragma solidity ^0.6.0; //确定运行的版本号 contract SimpleStorage { //合约定义 uint storedData; //声明变量 function set(uint x) public { //set方法 storedData = x; //参数赋值 } function get() public view returns (uint) { //get方法 return storedData; //返回该变量 } } Note: If there are any errors, please feel free to communicate rationally! ,Thanks!

Guess you like

Origin blog.csdn.net/y943711797/article/details/132972206