tx · CqsH8PtrWFvtAwXtrH4oHzE5gQc3WDC66X68RJifrQ7g

3MrNiRZefEnuJXqnaQbCKLDGaKXYfSwEBD2:  -0.01000000 Waves

2019.07.06 21:42 [574074] smart account 3MrNiRZefEnuJXqnaQbCKLDGaKXYfSwEBD2 > SELF 0.00000000 Waves

{ "type": 13, "id": "CqsH8PtrWFvtAwXtrH4oHzE5gQc3WDC66X68RJifrQ7g", "fee": 1000000, "feeAssetId": null, "timestamp": 1562438549857, "version": 1, "sender": "3MrNiRZefEnuJXqnaQbCKLDGaKXYfSwEBD2", "senderPublicKey": "5k4QuWwevEZfkg4vLAVYsLDifqP2hDcQthWBnJXG9Sgm", "proofs": [ "4mDrASoThhxC2tScFtLs9qjoanSZGMhAfJ44xp4MM6M9i6NG1PVs4SNDgUiicbW2M3DLZfQkJ7WBSAXWJ52uMes7" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAA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HVzZXIFAAAABHZvdGUJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA9nZXRLZXlWb3RlQ291bnQAAAACBQAAAARpdGVtBQAAAAR2b3RlBQAAAAxuZXdWb3RlQ291bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABBnZXRLZXlJdGVtU3RhdHVzAAAAAQUAAAAEaXRlbQMJAABnAAAAAgUAAAAMbmV3Vm90ZUNvdW50BQAAAAZRVU9SVU0FAAAABHZvdGUFAAAABlJFVkVBTAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmdmcXR", "chainId": 84, "height": 574074, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
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+func getNumberByKey (key) = {
19+ let num = match getInteger(this, key) {
20+ case a: Int =>
21+ a
22+ case _ =>
23+ 0
24+ }
25+ num
26+ }
27+
28+
29+func getStrByKey (key) = {
30+ let str = match getString(this, key) {
31+ case a: String =>
32+ a
33+ case _ =>
34+ NONE
35+ }
36+ str
37+ }
38+
39+
40+func getKeyItemPrice (item) = (item + "_price")
41+
42+
43+func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
44+
45+
46+func getKeyUserItemCounter (user,item) = ((item + "_user") + "_cnt")
47+
48+
49+func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
50+
51+
52+func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
53+
54+
55+func getKeyItemData (item) = (item + "_data")
56+
57+
58+func getKeyItemSupplier (item) = (item + "_owner")
59+
60+
61+func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
62+
63+
64+func getKeyBalanceSupplier (account) = (account + "_balance")
65+
66+
67+func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
68+
69+
70+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
71+
72+
73+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
74+
75+
76+func getKeyCommitsCount (item) = (item + "_comcnt")
77+
78+
79+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
80+
81+
82+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
83+
84+
85+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
86+
87+
88+func getKeyItemStatus (item) = (item + "_status")
89+
90+
91+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
92+
93+
94+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
95+
96+
97+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
98+
99+
100+@Callable(i)
101+func addItem (title,price,data) = {
102+ let supplierAddress = toBase58String(i.caller.bytes)
103+ let item = getKeyItem(supplierAddress, title)
104+ if ((0 >= price))
105+ then throw("Purchase amount cannot be less that item price")
106+ else if ((getValueItemSupplier(item) != NONE))
107+ then throw("This item already exist")
108+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
109+ }
110+
111+
112+
113+@Callable(i)
114+func purchase (item) = {
115+ let pmt = extract(i.payment)
116+ if (isDefined(pmt.assetId))
117+ then throw("Waves token only at this moment")
118+ else {
119+ let userAddress = toBase58String(i.caller.bytes)
120+ let price = getValueItemPrice(item)
121+ let supplierAddress = getValueItemSupplier(item)
122+ if ((price > pmt.amount))
123+ then throw("Purchase amount can not be less than item price")
124+ else if ((pmt.amount > price))
125+ then throw("Purchase amount can not be higher than item price")
126+ else if ((supplierAddress == NONE))
127+ then throw("Supplier does not exist")
128+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
129+ }
130+ }
131+
132+
133+
134+@Callable(i)
135+func withdraw () = {
136+ let supplierAddress = toBase58String(i.caller.bytes)
137+ let balance = getValueBalanceSupplier(supplierAddress)
138+ if ((0 >= balance))
139+ then throw("Insufficient Balance")
140+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
141+ }
142+
143+
144+
145+@Callable(i)
146+func voteCommit (item,hash) = {
147+ let user = toBase58String(i.caller.bytes)
148+ let commits = getValueCommitsCount(item)
149+ let status = getValueItemStatus(item)
150+ if ((commits >= VOTERS))
151+ then throw("Reached max numbers of voters")
152+ else if ((getValueCommit(item, user) != NONE))
153+ then throw("User has already participated")
154+ else if ((getKeyItemSupplier(item) == NONE))
155+ then throw("Item does not exist")
156+ else if (if ((status != NONE))
157+ then (status != VOTING)
158+ else false)
159+ then throw("Voting is not possible")
160+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
161+ then REVEAL
162+ else VOTING)])
163+ }
164+
165+
166+
167+@Callable(i)
168+func voteReveal (item,vote,salt) = {
169+ let user = toBase58String(i.caller.bytes)
170+ let status = getValueItemStatus(item)
171+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
172+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
173+ then throw("reveal data is not valid")
174+ else if ((VOTERS > getValueCommitsCount(item)))
175+ then throw("Max number of votes hasn't been reached yet")
176+ else if ((getValueReveal(item, user) != NONE))
177+ then throw("user has already participated")
178+ else if (if ((status != VOTING))
179+ then (status != REVEAL)
180+ else false)
181+ then throw("wrong status")
182+ else if (if ((vote != FEATURED))
183+ then (vote != DELISTED)
184+ else false)
185+ then throw("wrong vote")
186+ else if (if ((status == FEATURED))
187+ then true
188+ else (status == DELISTED))
189+ then throw("Vote has finished")
190+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
191+ then vote
192+ else REVEAL)])
193+ }
194+
195+
196+@Verifier(tx)
197+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
198+

github/deemru/w8io/026f985 
31.16 ms