Snippets
Created by
Alex Mizrahi
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | (defcontract futuristic ()
(fields
(buyer :type pubkey :init nil)
(seller :type pubkey)
(broker :type pubkey :init nil)
(sellers_bank :type pubkey :init nil)
(buyers_bank :type pubkey :init nil)
(land_registry :type pubkey :init nil)
(property :type string :init nil)
(price :type string :init nil)
(description :type string :init nil)
(security_info :type string :init nil) ; should be a list type of sorts maybe, or json string
(state :type string :init nil)
)
(actions
(offer ((property-id string :description "Official ID of the property"))
"Offer the property on the market (pending description of the property by the broker)"
(guard
(signatures seller)
(eql state nil))
(update property property-id
state :invite-broker)
)
(invite-broker ((broker-pk pubkey))
"Invitation of broker to the contract"
(guard
(signatures seller)
(eql state :invite-broker)
(eql broker nil))
(locally
(invite broker-pk))
(update broker broker-pk
state :describe)
)
(describe ((description-param string :description "Description of the property, including it's state"))
"Describe the property, including its extent and state"
(guard
(signatures broker)
(eql state :describe)
)
(update description description-param
state :invite-buyer)
)
(invite-buyer ((buyer-pk pubkey))
"You are invited as buyer to put a bid on the property"
(guard
(signatures broker)
(eql state :invite-buyer)
)
(locally
(invite buyer-pk)
)
(update buyer buyer-pk
state :bid)
)
(bid ((bid-amount string :description "Price offered for buying the property"))
"Enter your bid for the property"
(guard
(signatures buyer)
(eql state :bid)
)
(update price bid-amount
state :accept)
)
(accept ()
"Accept the bid for the property"
(guard
(signatures seller)
(not (eql price nil))
(eql state :accept)
)
(update state :commit)
)
(commit ()
"Commit to your bid for the property"
(guard
(signatures buyer)
(not (eql price nil))
(eql state :commit)
)
(update state :invite-sellers_bank)
)
(invite-sellers_bank ((sellers_bank-pk pubkey))
"Invite the bank that will handle the sale"
(guard
(signatures seller)
(eql sellers_bank nil)
(eql state :invite-sellers_bank)
)
(locally
(invite sellers_bank-pk)
)
(update sellers_bank sellers_bank-pk
state :security)
)
(security ((security-info string :description "Ordered collection of mortgage deeds"))
"Supply the mortgage deeds for this property"
(guard
(signatures sellers_bank)
(eql state :security)
)
(update security_info security-info
state :invite-buyers_bank)
)
(invite-buyers_bank ((buyers_bank-pk pubkey))
"Invite the bank that will handle the purchase"
(guard
(signatures seller)
(eql buyers_bank nil)
(eql state :invite-buyers_bank)
)
(locally
(invite buyers_bank-pk)
)
(update buyers_bank buyers_bank-pk
state :pay)
)
(pay ((amount string :description "Buyer's bank commits to pay this amount to seller") )
"Commit to paying the seller"
(guard
(signatures buyers_bank)
; (eql price amount) you cannot refer to params in guard clause
(eql state :pay)
)
(update state :possession)
)
(possession ()
"Vouch that the buyer is now in possession of the property"
(guard
(signatures broker)
(eql state :possession)
)
(update state :invite-land_registry)
)
(invite-land_registry ((land_registry-pk pubkey))
"Ask the Land Registry to close the contract"
(guard
(signatures broker)
(eql state :invite-land_registry)
)
(locally
(invite land_registry-pk)
)
(update land_registry land_registry-pk
state :title)
)
(title ()
"Transfer the title to the new owner for this property"
(guard
(signatures land_registry)
(eql state :title)
)
(update state :title_transferred)
)
))
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.