Solidity, a new beginning for language

Official website

WTF-Solidity official website
compiler

The basics of blockchain

Insert image description here

Gas

Once created, each transaction is charged a certain amount of gas in order to limit the amount of work required to execute the transaction and pay fees for the transaction. When the EVM executes transactions, gas will be gradually exhausted according to specific rules.
The gas price is a value set by the transaction sender, and the sender's account needs to prepay a handling fee = gas_price * gas. If there is any remaining gas after the transaction is executed, the gas will be returned along the way.
No matter where the execution reaches, once the gas is exhausted (such as falling to a negative value), an out-of-gas exception will be triggered. All state modifications made during the current call frame will be rolled back.

Hello Word small example

code

/*
* title 一个简单的数据存储演示
* author 忆梦九洲
*/
//软件许可(license),这里用的是MIT license。如果不写许可,编译时会警告(warning)
// SPDX-License-Identifier: MIT
//源文件所用的solidity版本
pragma solidity ^0.8.4;
// 合约的名字-->HelloWeb3
contract HelloWeb3{
    
    
//合约的内容
string public _string = "Hello Web3!"; //状态变量
//函数
function fun1() public view returns (string memory){
    
    
   return _string;
   }

bool public _bool =true;

} 

Insert image description here

gas is just a reference, not particularly accurate

Remix tool usage

Insert image description here

If automatic compilation is not turned on, you can use the code editing page and press ctrl+S to compile the code, which is very convenient.

Remix execution process

By default, remix will use a JS virtual machine to simulate the Ethereum chain and run smart contracts, similar to running a test chain in a browser. And remix will allocate several test accounts to you, each with 100 ETH (test tokens), which can be used vigorously. If you click Deploy (yellow button), you can deploy the contract we wrote.
Insert image description here

Switch to Chinese

Insert image description here

Comment

//:Single line comment

/* */: block comments
Insert image description here

The first two comments are similar to those used in other languages ​​such as java, Python, c, etc.

NatSpec description comment: '///'

-Demonstration

-document

-Inheritance instructions

 -重载

Guess you like

Origin blog.csdn.net/Wtzink/article/details/134231750