tx · 717s9HMkSsMqNqc7RyK9m1QSePsx4Jwb1AV59MX4nu2V

3MvgxS9JmLvNSyx4dJr6Zfke3Siz5p92gao:  -0.01400000 Waves

2019.09.06 01:36 [663349] smart account 3MvgxS9JmLvNSyx4dJr6Zfke3Siz5p92gao > SELF 0.00000000 Waves

{ "type": 13, "id": "717s9HMkSsMqNqc7RyK9m1QSePsx4Jwb1AV59MX4nu2V", "fee": 1400000, "feeAssetId": null, "timestamp": 1567723074874, "version": 1, "sender": "3MvgxS9JmLvNSyx4dJr6Zfke3Siz5p92gao", "senderPublicKey": "DtnvSHiYQnjG4si66eUE3pTReZAnukP13TFUr4QtsJBc", "proofs": [ "67jtFSn1S8sxFavKiV97NwbeRvfM2NGfV129JCA8VDqQct9UQSxXU8gUeZcB7PXNmfBjxcQ6zHWTVr99hruJukzT" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAAAAAABOIj1q", "chainId": 84, "height": 663349, "spentComplexity": 0 } View: original | compacted Prev: 63zUuC8xskeSjxiy9s8cawR4tHhawpcMQm7hF2pbbLvD Next: 7DBSNH8rrz7CqHkwkhpexxPtMVnhrip8fQoPbXs41qTi Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let NONE = "none"
54
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))
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 than price")
106- else if ((getValueItemSupplier(item) != NONE))
107- then throw("item already exists")
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 the 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 cannot be less than item price")
124- else if ((pmt.amount > price))
125- then throw("purchase cannot be higher than item price")
126- else if ((supplierAddress == NONE))
127- then throw("supplier does not exists")
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("bad 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 num 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- }
1645
1656

github/deemru/w8io/169f3d6 
33.45 ms