区块链2.0以太坊智能合约solidity之helloworld

由于只能合约是放在区块链上面的代码,这给我们的调试带来了很多的困难,还好有在线的编译器:

https://remix.ethereum.org

第一个代码:
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);
}
}

}


第一行代表solidity的版本,^代表向上兼容版本5.0

第二行contract Counter为一个智能合约类对象

第三行、四行为属性:

uint count = 0;

address owner;

下面是三个函数,其中构造函数为:

constructor() public
{
  owner = msg.sender;  

}










网址:http://www.qukuailianxueyuan.io/



欲领取造币技术与全套虚拟机资料

区块链技术交流QQ群:756146052  备注:CSDN

尹成学院微信:备注:CSDN


猜你喜欢

转载自blog.csdn.net/yincheng01/article/details/80153272