……

为简单起见,我们使用在线Solidity开发工具Remix IDE编译和运行Solidity程序。

第1步 – 在File explorers选项卡下,新建一个test1.sol文件,代码如下:

示例

pragma solidity ^0.5.0;
contract SolidityTest {
   constructor() public{
   }
   function getResult() public view returns(uint){
      uint a = 1;
      uint b = 2;
      uint result = a + b;
      return result;
   }
}

第2步 – 在Compiler选项卡下,单击 Compile 按钮,开始编译
第3步 – 在Run选项卡下,单击 Deploy 按钮进行部署
第4步 – 在Run选项卡下,选择 SolidityTest at 0x… 下拉
第5步 – 单击 getResult 按钮显示结果。

输出

0: uint256: 3

 

 posted on 2020-06-23 16:26  大码王  阅读(403)  评论(0编辑  收藏  举报
复制代码