更新一些学习内容
parent
4f2213d902
commit
4dd8b0fefa
@ -0,0 +1,47 @@
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
import "solidity_for_import.sol";
|
||||
|
||||
// this is a test Contract
|
||||
|
||||
contract Test{
|
||||
// 状态变量定义
|
||||
uint a;
|
||||
bool boola = true;
|
||||
bool boolb = false;
|
||||
|
||||
|
||||
|
||||
// 函数定义
|
||||
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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
|
||||
// this is a ForImport Contract
|
||||
|
||||
contract ForImport{
|
||||
|
||||
}
|
Loading…
Reference in New Issue