pragma solidity ^0.4.0; import "solidity_for_import.sol"; // this is a test Contract contract Test{ // 状态变量定义 uint a; int256 b = 20; int256 c = 30; bool boola = true; bool boolb = false; function testInt() public returns (int) { if (b > c){ return b + c; }else if(b == c){ return b * c; }else { return b << 2; // b / 2^2 } -1 >> 2; } // 函数定义 function setA(uint x) public { a = x; // 触发事件 -> 可以监听这个事件, 获取到对应的值 emit Set_A(x); } // 定义事件 event Set_A(uint a); // 定义结构类型 struct Position{ int lat; int lng; } address public ownerAddr; // 函数修改器 - 类似于 python 的装饰器, 可以修改函数的行为 modifier owner(){ // 在调用 mine 之前先进行校验 require(msg.sender == ownerAddr); // mine 的代码会插入到这个位置 _; } // 只有 owner 才能调用这个函数 function mine() public owner { } }