HelloWorld of blockchain 2.0 Ethereum smart contract solidity

Yin Cheng 2021-11-24 08:07:56 阅读数:383

helloworld blockchain ethereum smart contract

Because the contract can only be the code placed on the blockchain , This brings us a lot of difficulties in debugging , Fortunately, there is an online compiler :

https://remix.ethereum.org

The first code :
pragma solidity ^0.4.4;
contract Counter {
uint count = 0;
address owner;


constructor() public
{
  owner = msg.sender;  
}


function increment() public {
uint step = 10;
if (owner == msg.sender) {
count = count + step;
}
}
function getCount() constant public returns (uint)  {
return count;
}
function kill() public {

if (owner == msg.sender) {
selfdestruct(owner);
}
}

}


The first line stands for solidity Version of ,^ Represents an upward compatible version 5.0

The second line contract Counter As a smart contract class object

The third line 、 Four behavior attributes :

uint count = 0;

address owner;

Here are three functions , Where the constructor is :

constructor() public
{
  owner = msg.sender;  

}










website :http://www.qukuailianxueyuan.io/



Want to get the coinage technology and a full set of virtual machine information

Blockchain technology exchange QQ Group :756146052   remarks :CSDN

Wechat of Yin Cheng College : remarks :CSDN


版权声明:本文为[Yin Cheng]所创,转载请带上原文链接,感谢。 https://netfreeman.com/2021/11/20211108224341545k.html