Skip to content

Instantly share code, notes, and snippets.

@easyforgood
Created August 31, 2018 11:01
Show Gist options
  • Save easyforgood/69d9061cb6d592888f628cf29232d087 to your computer and use it in GitHub Desktop.
Save easyforgood/69d9061cb6d592888f628cf29232d087 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.18;
contract Gate {
bytes8 private password;
address public entrant;
address private mainContract;
uint public tryLimit=0;
struct User {
bytes8 username;
bytes8 password;
}
uint public win_pos;
function Gate(uint _win_pos, bytes8 _password) public{
mainContract = msg.sender;
win_pos = _win_pos;
password = _password;
}
modifier isLimit() {
require(tryLimit<3); tryLimit++; _;
}
modifier gateKeeperOne() {
require(bytes20(tx.origin)[0]==bytes1(0xca));
require(bytes20(tx.origin)[1]==bytes1(0x35));
User user;
user.password=bytes8(msg.sender) << 2;
user.username=bytes8(msg.sender) << 5; _;
}
modifier gateKeeperTwo() {
if(win_pos>0){
require(msg.gas % 8191 < 700); require(msg.gas % 8191> 200);
}
_;
}
modifier gateKeeperThree(bytes8 _gateKey) {
if(win_pos>1){
require(_gateKey == password);
}
_;
}
function enter(bytes8 _gateKey) public isLimit gateKeeperOne gateKeeperTwo gateKeeperThree(_gateKey) returns(bool) {
entrant = tx.origin;
return true;
}
function submit() public returns (bool){
GameBuilder build=GameBuilder(mainContract);
return build.win();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment