Verified contractPartial
RockPaperScissors
Address0xb91c24ceafa88c8829360a030b8f5e23cffacd04
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.1.4
- Same code
Only this contract
Details
- Compiler
- solc 0.1.4+commit.5f6c3cdf
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: no, runtime code: yes
- Verified on Sourcify
- Created in block
- 416,575
- Creation transaction
- 0x920489515d…ec6303c6ac
RockPaperScissors.sol
// Recovered by EthereumHistory (ethereumhistory.com) -sw
contract RockPaperScissors {
struct Player {
address addr;
uint choice;
}
Player[2] public player;
uint public num_players;
uint public reward;
uint[3][3] public check_winner;
function RockPaperScissors() {
check_winner[0][0] = 2;
check_winner[1][1] = 2;
check_winner[2][2] = 2;
check_winner[0][2] = 0;
check_winner[2][0] = 1;
check_winner[2][1] = 0;
check_winner[1][2] = 1;
check_winner[1][0] = 0;
check_winner[0][1] = 1;
num_players = 0;
}
function add_player(uint choice) returns (int) {
if (num_players < 2) {
reward = reward + msg.value;
player[num_players].addr = msg.sender;
player[num_players].choice = choice;
num_players = num_players + 1;
return 0;
} else
return -1;
}
function check() returns (int) {
uint p1 = player[0].choice;
uint p2 = player[1].choice;
if (check_winner[p1][p2] == 0) {
player[0].addr.send(reward);
return 0;
} else if (check_winner[p1][p2] == 1) {
player[1].addr.send(reward);
return 1;
} else {
player[0].addr.send(reward / 2);
player[1].addr.send(reward / 2);
return 2;
}
}
function balance_check() returns (uint b1, uint b2) {
b1 = player[0].addr.balance;
b2 = player[1].addr.balance;
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.