1pragma solidity ^0.4.20; 2 3pragma solidity >=0.4.0 <0.7.0; 4 5// one-line singleline comment 6 7/* one-line multiline comment */ 8 9/* 10 multi-line multiline comment 11*/ 12 13contract ContractName { 14 15 address public publicaddress; 16 17 uint varname1 = 1234; 18 int varname2 = 0x12abcdEF; 19 20 string astringsingle = 'test "string" value\' single'; 21 string astringdouble = "test 'string' value\" double"; 22 23 enum State { 24 NotStarted, 25 WorkInProgress, 26 Done 27 } 28 State public state; 29 30 struct AStruct { 31 string name; 32 uint8 type; 33 } 34 35 mapping(address => AStruct) registry; 36 37 event Paid(uint256 value); 38 event Received(uint256 time); 39 event Withdraw(uint256 value); 40 41 function addRegistry(string _name, uint8 _type) { 42 AStruct memory newItem = AStruct({ 43 name: _name, 44 type: _type 45 }); 46 47 registry[msg.sender] = newItem; 48 } 49 50 function getHash(AStruct item) returns(uint) { 51 return uint(keccak256(item.name, item.type)); 52 } 53 54 function pay() public payable { 55 require(msg.sender == astronaut); 56 state = State.Paid; 57 Paid(msg.value); 58 } 59 60 function receive() public { 61 require(msg.sender == arbiter); 62 require(state == State.Paid); 63 state = State.Received; 64 Received(now); 65 } 66 67 function withdraw() public { 68 require(msg.sender == shipper); 69 require(state == State.Received); 70 state = State.Withdrawn; 71 Withdraw(this.balance); 72 shipper.transfer(this.balance); 73 } 74} 75