Demo1

作者: 蜗牛也有梦想 | 来源:发表于2019-04-28 17:11 被阅读0次

pragma solidity 0.5.1;

// contract MyContract2{
// uint256 public peopleCount = 0;
// mapping(uint => Person) public people;
// struct Person{
// uint _id;
// string _firstName;
// string _lastName;
// }

// function addPerson(string memory _firstName,string memory _lastName) public{
// peopleCount += 1;
// people[peopleCount] = Person(peopleCount,_firstName,_lastName);
// }
// }

// contract MyContract3{
// uint256 public peopleCount = 0;
// mapping(uint => Person) public people;
// struct Person{
// uint _id;
// string _firstName;
// string _lastName;
// }

// function addPerson(string memory _firstName,string memory _lastName) public{
// incrementCount();
// people[peopleCount] = Person(peopleCount,_firstName,_lastName);
// }

// function incrementCount() internal{
// peopleCount += 1;
// }
// }

// 限制拥有者才能操作
// contract MyContract4{
// uint256 public peopleCount = 0;
// mapping(uint => Person) public people;

// address owner;
// modifier onlyOwner(){
// require(msg.sender == owner,"not owner");
// _;
// }

// struct Person{
// uint _id;
// string _firstName;
// string _lastName;
// }

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

// function addPerson(string memory _firstName,string memory _lastName) public onlyOwner{
// incrementCount();
// people[peopleCount] = Person(peopleCount,_firstName,_lastName);
// }

// function incrementCount() internal{
// peopleCount += 1;
// }
// }

// 限制开放时间
// contract MyContract5{
// uint256 public peopleCount = 0;
// mapping(uint => Person) public people;

// uint256 openingTime = 1556181850;
// modifier onlyWhileOpen(){
// require(block.timestamp >= openingTime,"not reach open time");
// _;
// }

// struct Person{
// uint _id;
// string _firstName;
// string _lastName;
// }

// function addPerson(string memory _firstName,string memory _lastName) public onlyWhileOpen{
// incrementCount();
// people[peopleCount] = Person(peopleCount,_firstName,_lastName);
// }

// function incrementCount() internal{
// peopleCount += 1;
// }
// }

// 利用event查看log
// contract MyContract6{
// mapping(address => uint256) public balances;
// address payable wallet;

// event Purchase(address indexed _buyer,uint256 _amount);

// constructor(address payable _wallect) public{
// wallet = _wallect;
// }

// function() external payable{
// buyToken();
// }

// function buyToken() public payable{
// balances[msg.sender] += 1;
// wallet.transfer(msg.value);
// emit Purchase(msg.sender,1);
// }
// }

相关文章

网友评论

      本文标题:Demo1

      本文链接:https://www.haomeiwen.com/subject/jujjnqtx.html