blob: f7a6495ecb34c057888835d3ff20a6f0c49443ed (
plain)
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
71
72
73
74
|
pragma solidity ^0.4.20;
pragma solidity >=0.4.0 <0.7.0;
// one-line singleline comment
/* one-line multiline comment */
/*
multi-line multiline comment
*/
contract ContractName {
address public publicaddress;
uint varname1 = 1234;
int varname2 = 0x12abcdEF;
string astringsingle = 'test "string" value\' single';
string astringdouble = "test 'string' value\" double";
enum State {
NotStarted,
WorkInProgress,
Done
}
State public state;
struct AStruct {
string name;
uint8 type;
}
mapping(address => AStruct) registry;
event Paid(uint256 value);
event Received(uint256 time);
event Withdraw(uint256 value);
function addRegistry(string _name, uint8 _type) {
AStruct memory newItem = AStruct({
name: _name,
type: _type
});
registry[msg.sender] = newItem;
}
function getHash(AStruct item) returns(uint) {
return uint(keccak256(item.name, item.type));
}
function pay() public payable {
require(msg.sender == astronaut);
state = State.Paid;
Paid(msg.value);
}
function receive() public {
require(msg.sender == arbiter);
require(state == State.Paid);
state = State.Received;
Received(now);
}
function withdraw() public {
require(msg.sender == shipper);
require(state == State.Received);
state = State.Withdrawn;
Withdraw(this.balance);
shipper.transfer(this.balance);
}
}
|