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