tx · H6CWVnaFTEfwCXRp7SbNtyxXSjkfqa2mhpkWSjun9gPL 3MyZc63LNUPHStRm6Y38NTQGzPjDREyqiRf: -0.01400000 Waves 2019.08.10 00:58 [624025] smart account 3MyZc63LNUPHStRm6Y38NTQGzPjDREyqiRf > SELF 0.00000000 Waves
{ "type": 13, "id": "H6CWVnaFTEfwCXRp7SbNtyxXSjkfqa2mhpkWSjun9gPL", "fee": 1400000, "feeAssetId": null, "timestamp": 1565387966989, "version": 1, "sender": "3MyZc63LNUPHStRm6Y38NTQGzPjDREyqiRf", "senderPublicKey": "FGm3vtnGW6r9XgBJwAL6exsKRRNxhnEB5XiYUGpuPpUF", "proofs": [ "4HGSzc7k1Dv9ukqtSbvEhKQVhdczYVQ2Te47Qsh1XvP849TuaK1zZ2LRCDkm4fZCddAM9AdjeXvTUCf6ZNvUwz3K" ], "script": "base64:AAIDAAAAAAAAAAAAAAAeAAAAAA5vd25lclB1YmxpY0tleQEAAAAg1A0jHW4eYnreOBL3AcnEKQv0VAasfV1qCc5r5ai9CRgAAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNURUQCAAAACGRlbGlzdGVkAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAH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dGVtIGlzIGFscmVhZHkgZXhpc3QJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABJnZXRLZXlJdGVtU3VwcGxpZXIAAAABBQAAAARpdGVtBQAAAA9zdXBwbGllckFkZHJlc3MJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABBQAAAARpdGVtBQAAAAVwcmljZQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAADmdldEtleUl0ZW1EYXRhAAAAAQUAAAAEaXRlbQUAAAAEZGF0YQUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAOb3duZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGB/hxj5I=", "chainId": 84, "height": 624025, "spentComplexity": 0 } View: original | compacted Prev: none Next: BVRiNuxqVnhZrnED9hQRixz6KqEu3G1mz3oU5PukqoxC Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let ownerPublicKey = base58'FGm3vtnGW6r9XgBJwAL6exsKRRNxhnEB5XiYUGpuPpUF' | |
5 | + | ||
6 | + | let NONE = "none" | |
7 | + | ||
8 | + | let VOTERS = 3 | |
9 | + | ||
10 | + | let QUORUM = 2 | |
11 | + | ||
12 | + | let VOTING = "voting" | |
13 | + | ||
14 | + | let REVEAL = "reveal" | |
15 | + | ||
16 | + | let FEATURED = "featured" | |
17 | + | ||
18 | + | let DELISTED = "delisted" | |
19 | + | ||
20 | + | func getNumberByKey (key) = { | |
21 | + | let num = match getInteger(this, key) { | |
22 | + | case a: Int => | |
23 | + | a | |
24 | + | case _ => | |
25 | + | 0 | |
26 | + | } | |
27 | + | num | |
28 | + | } | |
29 | + | ||
30 | + | ||
31 | + | func getStrByKey (key) = { | |
32 | + | let str = match getString(this, key) { | |
33 | + | case a: String => | |
34 | + | a | |
35 | + | case _ => | |
36 | + | NONE | |
37 | + | } | |
38 | + | str | |
39 | + | } | |
40 | + | ||
41 | + | ||
42 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
43 | + | ||
44 | + | ||
45 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
46 | + | ||
47 | + | ||
48 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
49 | + | ||
50 | + | ||
51 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
52 | + | ||
53 | + | ||
54 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
55 | + | ||
56 | + | ||
57 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
58 | + | ||
59 | + | ||
60 | + | func getKeyItemStatus (item) = (item + "_status") | |
61 | + | ||
62 | + | ||
63 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
64 | + | ||
65 | + | ||
66 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
67 | + | ||
68 | + | ||
69 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
70 | + | ||
71 | + | ||
72 | + | func getKeyItemPrice (item) = (item + "_price") | |
73 | + | ||
74 | + | ||
75 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
76 | + | ||
77 | + | ||
78 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
79 | + | ||
80 | + | ||
81 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
82 | + | ||
83 | + | ||
84 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
85 | + | ||
86 | + | ||
87 | + | func getKeyItemData (item) = (item + "_data") | |
88 | + | ||
89 | + | ||
90 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
91 | + | ||
92 | + | ||
93 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
94 | + | ||
95 | + | ||
96 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
97 | + | ||
98 | + | ||
99 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
100 | + | ||
101 | + | ||
102 | + | @Callable(i) | |
103 | + | func voteReveal (item,vote,salt) = { | |
104 | + | let user = toBase58String(i.caller.bytes) | |
105 | + | let status = getValueItemStatus(item) | |
106 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
107 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
108 | + | then throw("reveal data is not valid") | |
109 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
110 | + | then throw("max num of voters hasn't been reached yet") | |
111 | + | else if ((getValueReveal(item, user) != NONE)) | |
112 | + | then throw("user has already participated") | |
113 | + | else if (if ((status != VOTING)) | |
114 | + | then (status != REVEAL) | |
115 | + | else false) | |
116 | + | then throw("wrong status") | |
117 | + | else if (if ((vote != FEATURED)) | |
118 | + | then (vote != DELISTED) | |
119 | + | else false) | |
120 | + | then throw("wrong vote") | |
121 | + | else if (if ((status == FEATURED)) | |
122 | + | then true | |
123 | + | else (status == DELISTED)) | |
124 | + | then throw("vote has finished") | |
125 | + | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
126 | + | then vote | |
127 | + | else REVEAL)]) | |
128 | + | } | |
129 | + | ||
130 | + | ||
131 | + | ||
132 | + | @Callable(i) | |
133 | + | func voteCommit (item,hash) = { | |
134 | + | let user = toBase58String(i.caller.bytes) | |
135 | + | let commits = getValueCommitsCount(item) | |
136 | + | let status = getValueItemStatus(item) | |
137 | + | if ((commits >= VOTERS)) | |
138 | + | then throw("reached max num of voters") | |
139 | + | else if ((getValueCommit(item, user) != NONE)) | |
140 | + | then throw("user has already participated") | |
141 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
142 | + | then throw("item does not exist") | |
143 | + | else if (if ((status != NONE)) | |
144 | + | then (status != VOTING) | |
145 | + | else false) | |
146 | + | then throw("voting is not possible") | |
147 | + | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
148 | + | then REVEAL | |
149 | + | else VOTING)]) | |
150 | + | } | |
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | @Callable(i) | |
155 | + | func purchase (item) = { | |
156 | + | let pmt = extract(i.payment) | |
157 | + | if (isDefined(pmt.assetId)) | |
158 | + | then throw("can use WAVES only at the moment") | |
159 | + | else { | |
160 | + | let userAddress = toBase58String(i.caller.bytes) | |
161 | + | let price = getValueItemPrice(item) | |
162 | + | let supplierAddress = getValueItemSupplier(item) | |
163 | + | if ((price > pmt.amount)) | |
164 | + | then throw("purchase amount cannot be less than item price") | |
165 | + | else if ((pmt.amount > price)) | |
166 | + | then throw("purchase amount cannot be higher than item price") | |
167 | + | else if ((supplierAddress == NONE)) | |
168 | + | then throw("supplier does not exist") | |
169 | + | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
170 | + | } | |
171 | + | } | |
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | @Callable(i) | |
176 | + | func withdraw () = { | |
177 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
178 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
179 | + | if ((0 >= balance)) | |
180 | + | then throw("insufficient balance") | |
181 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
182 | + | } | |
183 | + | ||
184 | + | ||
185 | + | ||
186 | + | @Callable(i) | |
187 | + | func addItem (title,price,data) = { | |
188 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
189 | + | let item = getKeyItem(supplierAddress, title) | |
190 | + | if ((0 >= price)) | |
191 | + | then throw("purchase amount cannot be less than item price") | |
192 | + | else if ((getValueItemSupplier(item) != NONE)) | |
193 | + | then throw("an item is already exist") | |
194 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
195 | + | } | |
196 | + | ||
197 | + | ||
198 | + | @Verifier(tx) | |
199 | + | func verify () = match tx { | |
200 | + | case d: SetScriptTransaction => | |
201 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
202 | + | case d: DataTransaction => | |
203 | + | true | |
204 | + | case d: TransferTransaction => | |
205 | + | true | |
206 | + | case _ => | |
207 | + | false | |
208 | + | } | |
209 | + |
github/deemru/w8io/026f985 17.16 ms ◑