tx · BHv4ThBwR6kcmZS9QrRxDDsDBb8CP9SPhmJeDJxE7zAH

3N8X6wT7GZLavL2ayUQzwRD2kRFRSDyhkKS:  -0.01000000 Waves

2021.07.08 17:44 [1604766] smart account 3N8X6wT7GZLavL2ayUQzwRD2kRFRSDyhkKS > SELF 0.00000000 Waves

{ "type": 13, "id": "BHv4ThBwR6kcmZS9QrRxDDsDBb8CP9SPhmJeDJxE7zAH", "fee": 1000000, "feeAssetId": null, "timestamp": 1625755478095, "version": 2, "chainId": 84, "sender": "3N8X6wT7GZLavL2ayUQzwRD2kRFRSDyhkKS", "senderPublicKey": "7DT6yPGiY3eZiSytDKBx5ToZcjhem3SyxdX6Zz9fsMED", "proofs": [ "5AYy5BduPvGN5eyXiWPS8adRWe5BWihGcDF5AKwi11YMpmXqWhLGmrDX6Umj9AaKkdF7ZVJyxv65P2c5M3NmWnyb" ], "script": "base64:AAIFAAAAAAAAACUIAhIAGgcKAmExEgFpGggKAmEyEgJ0eBoMCgJhMxIGdmVyaWZ5AAAAAAAAAAEAAAACYTEBAAAABGNhbGwAAAAACQAETAAAAAIJAQAAAARCdXJuAAAAAgEAAAAgGCUhbruZPfMCI0X0UVU6mFh4CwlKB+ZqLmKOkPCC+TgAAAAAAAAAAAEFAAAAA25pbAAAAAEAAAACYTIBAAAAAmEzAAAAAAkAAfQAAAADCAUAAAACYTIAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJhMgAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJhMgAAAA9zZW5kZXJQdWJsaWNLZXn0pikk", "height": 1604766, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Gt8czhHGAEVx2AXzEXDg1eGJZ4Eygpggf7EM6zuNmYLX Next: G2dqrkaQ5JajeaGh1c79kUAwHKEL1aEJ2vA54XWnuCzj Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let NONE = "none"
5-
6-func getNumberByKey (key) = {
7- let num = match getInteger(this, key) {
8- case a: Int =>
9- a
10- case _ =>
11- 0
12- }
13- num
14- }
15-
16-
17-func getStrByKey (key) = {
18- let str = match getString(this, key) {
19- case a: String =>
20- a
21- case _ =>
22- NONE
23- }
24- str
25- }
26-
27-
28-func getKeyItemPrice (item) = (item + "_price")
29-
30-
31-func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
32-
33-
34-func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
35-
36-
37-func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
38-
39-
40-func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
41-
42-
43-func getKeyItemData (item) = (item + "_data")
44-
45-
46-func getKeyItemSupplier (item) = (item + "_owner")
47-
48-
49-func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
50-
51-
52-func getKeyBalanceSupplier (account) = (account + "_balance")
53-
54-
55-func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
56-
57-
58-let VOTERS = 3
59-
60-let QUORUM = 2
61-
62-let VOTING = "voting"
63-
64-let REVEAL = "reveal"
65-
66-let FEATURED = "featured"
67-
68-let DELISTED = "delisted"
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))
984
995
1006 @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 than item price")
106- else if ((getValueItemSupplier(item) != NONE))
107- then throw("an item already exists")
108- else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
109- }
7+func call () = [Burn(base58'2dFd9ZLYU2ZXQk1FACPmkxeAkHrm5X4mZthxSo8peYHd', 1)]
1108
1119
112-
113-@Callable(i)
114-func purchase (item) = {
115- let pmt = i.payments[0]
116- if (isDefined(pmt.assetId))
117- then throw("WAVES ONLY HHEUAWHEUAS")
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 cannot be less than item price")
124- else if ((supplierAddress == NONE))
125- then throw("Supplier does not exist")
126- else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]
127- }
128- }
129-
130-
131-
132-@Callable(i)
133-func withdraw () = {
134- let supplierAddress = toBase58String(i.caller.bytes)
135- let balance = getValueBalanceSupplier(supplierAddress)
136- if ((0 >= balance))
137- then throw("insuficient balance")
138- else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
139- }
140-
141-
142-
143-@Callable(i)
144-func voteCommit (item,hash) = {
145- let user = toBase58String(i.caller.bytes)
146- let commits = getValueCommitsCount(item)
147- let status = getValueItemStatus(item)
148- if ((commits >= VOTERS))
149- then throw("Reached max num of voters")
150- else if ((getValueCommit(item, user) != NONE))
151- then throw("b1")
152- else if ((getKeyItemSupplier(item) == NONE))
153- then throw("b2")
154- else if (if ((status != NONE))
155- then (status != VOTING)
156- else false)
157- then throw("b3")
158- else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
159- then REVEAL
160- else VOTING)]
161- }
162-
163-
164-
165-@Callable(i)
166-func voteReveal (item,vote,salt) = {
167- let user = toBase58String(i.caller.bytes)
168- let status = getValueItemStatus(item)
169- let newVoteCount = (getValueVoteCount(item, vote) + 1)
170- if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
171- then throw("Reveal data is not valid")
172- else if ((VOTERS > getValueCommitsCount(item)))
173- then throw("max num of voters hasnt reached yet")
174- else if ((getValueReveal(item, user) != NONE))
175- then throw("user has already participated")
176- else if (if ((status != VOTING))
177- then (status != REVEAL)
178- else false)
179- then throw("wrong status")
180- else if (if ((vote != FEATURED))
181- then (vote != DELISTED)
182- else false)
183- then throw("wrong vote")
184- else if (if ((status == FEATURED))
185- then true
186- else (status == DELISTED))
187- then throw("vote has finished")
188- else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
189- then vote
190- else REVEAL)]
191- }
192-
10+@Verifier(tx)
11+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
19312

github/deemru/w8io/873ac7e 
25.52 ms