Skip to content

Instantly share code, notes, and snippets.

@josefrichter
Created September 9, 2021 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josefrichter/32600b3850a2cd539854434a4b507b43 to your computer and use it in GitHub Desktop.
Save josefrichter/32600b3850a2cd539854434a4b507b43 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint256 public peopleCount;
mapping(uint => Person) public people;
address owner;
uint256 openingTime = 1631171503;
/// uint256 openingTime = 1631171803;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWhileOpen() {
require(block.timestamp >= openingTime);
_;
}
struct Person {
uint _id;
string _firstName;
string _lastName;
}
constructor() {
owner = msg.sender;
}
function addPerson(
string memory _firstName,
string memory _lastName
)
public
// onlyOwner
onlyWhileOpen
{
incrementCount();
people[peopleCount] = Person(peopleCount, _firstName, _lastName);
}
function incrementCount() internal {
peopleCount += 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment