tx · 7XriJkRMmLnsPcv5Zc78Q9KGZoFDFY1YiFkvZjxkQvy6

3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe:  -0.00700000 Waves

2022.09.28 16:16 [2249013] smart account 3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe > SELF 0.00000000 Waves

{ "type": 13, "id": "7XriJkRMmLnsPcv5Zc78Q9KGZoFDFY1YiFkvZjxkQvy6", "fee": 700000, "feeAssetId": null, "timestamp": 1664370984342, "version": 2, "chainId": 84, "sender": "3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe", "senderPublicKey": "FFVf3kC6HkjRMmf8W6Zr2bNKhJ5EN5W1vG44GbgvHd9Z", "proofs": [ "5ks3BVquihFkbBLCLLC26caM2bbFmwvce8ccMMSXfjwjvSWqxG81vdF9Vam2pBMhMERnqq2D7YQFoq5xgJn2uXD4" ], "script": "base64:AAIDAAAAAAAAAB8IARIDCgEIEgUKAwgBCBIAEgQKAggIEgUKAwgICBIAAAAAHgAAAAAETk9ORQIAAAAEbm9uZQAAAAAGd2F2ZWluAQAAACBLhiHTf+rXkwiBnk1C0Lx5Vb91PWJg6NhmCwWOSYBbuAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgU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ABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAD2dldEtleVZvdGVDb3VudAAAAAIFAAAABGl0ZW0FAAAABHZvdGUFAAAADG5ld1ZvdGVDb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAGcAAAACBQAAAAxuZXdWb3RlQ291bnQFAAAABVFPUlVNBQAAAAR2b3RlBQAAAAZSRVZFQUwFAAAAA25pbAAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAACIT0AAAACCAUAAAADcG10AAAAB2Fzc2V0SWQFAAAABndhdmVpbgkAAAIAAAABAgAAACJTb3JyeSwgb25seSBXQVZXRUlOIGZvciB0aGUgbW9tZW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAADWN1cnJlbnRBbW91bnQEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAKY3VycmVudEtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABAAAAAluZXdBbW91bnQJAABkAAAAAgUAAAANY3VycmVudEFtb3VudAgFAAAAA3BtdAAAAAZhbW91bnQJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkFAAAACW5ld0Ftb3VudAUAAAADbmlsAAAAAASW+dQ=", "height": 2249013, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9XdLjo5eNnZaZQ8VUQAX1Tu3dgabPUc7HrJyPhRWuYCS Next: none Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
5+
6+let wavein = base58'65pCrqjE5ZYunnfcodoG1mG1Kk26DNp7raSSSN1mwDAF'
57
68 func getNumberByKey (key) = {
79 let num = match getInteger(this, key) {
191193 }
192194
193195
196+
197+@Callable(i)
198+func deposit () = {
199+ let pmt = extract(i.payment)
200+ if ((pmt.assetId != wavein))
201+ then throw("Sorry, only WAVWEIN for the moment")
202+ else {
203+ let currentKey = toBase58String(i.caller.bytes)
204+ let currentAmount = match getInteger(this, currentKey) {
205+ case a: Int =>
206+ a
207+ case _ =>
208+ 0
209+ }
210+ let newAmount = (currentAmount + pmt.amount)
211+ WriteSet([DataEntry(currentKey, newAmount)])
212+ }
213+ }
214+
215+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
5+
6+let wavein = base58'65pCrqjE5ZYunnfcodoG1mG1Kk26DNp7raSSSN1mwDAF'
57
68 func getNumberByKey (key) = {
79 let num = match getInteger(this, key) {
810 case a: Int =>
911 a
1012 case _ =>
1113 0
1214 }
1315 num
1416 }
1517
1618
1719 func getStrByKey (key) = {
1820 let str = match getString(this, key) {
1921 case a: String =>
2022 a
2123 case _ =>
2224 NONE
2325 }
2426 str
2527 }
2628
2729
2830 func getKeyItemPrice (item) = (item + "_price")
2931
3032
3133 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3234
3335
3436 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3537
3638
3739 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
3840
3941
4042 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4143
4244
4345 func getKeyItemData (item) = (item + "_data")
4446
4547
4648 func getKeyItemSupplier (item) = (item + "_owner")
4749
4850
4951 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5052
5153
5254 func getKeyBalanceSupplier (account) = (account + "_balance")
5355
5456
5557 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5658
5759
5860 let VOTERS = 3
5961
6062 let QORUM = 2
6163
6264 let VOTING = "voting"
6365
6466 let REVEAL = "reveal"
6567
6668 let FEATURED = "featured"
6769
6870 let DELISTED = "delisted"
6971
7072 func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
7173
7274
7375 func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
7476
7577
7678 func getKeyCommitsCount (item) = (item + "_comcnt")
7779
7880
7981 func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
8082
8183
8284 func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
8385
8486
8587 func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
8688
8789
8890 func getKeyItemStatus (item) = (item + "_status")
8991
9092
9193 func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
9294
9395
9496 func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
9597
9698
9799 func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
98100
99101
100102 @Callable(i)
101103 func purchase (item) = {
102104 let pmt = extract(i.payment)
103105 if (isDefined(pmt.assetId))
104106 then throw("can use WAVES only at the moment")
105107 else {
106108 let userAddress = toBase58String(i.caller.bytes)
107109 let price = getValueItemPrice(item)
108110 let supplierAddress = getValueItemSupplier(item)
109111 if ((pmt.amount != price))
110112 then throw("Purchase amount should be equal to price ")
111113 else if ((supplierAddress == NONE))
112114 then throw("The supplier does not exist")
113115 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
114116 }
115117 }
116118
117119
118120
119121 @Callable(i)
120122 func addItem (title,price,data) = {
121123 let supplierAddress = toBase58String(i.caller.bytes)
122124 let item = getKeyItem(supplierAddress, title)
123125 if ((0 >= price))
124126 then throw("purchase cannot be less than the item price")
125127 else if ((getValueItemSupplier(item) != NONE))
126128 then throw("The item already exitsts")
127129 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
128130 }
129131
130132
131133
132134 @Callable(i)
133135 func withdraw () = {
134136 let supplierAddress = toBase58String(i.caller.bytes)
135137 let balance = getValueBalanceSupplier(supplierAddress)
136138 if ((0 >= balance))
137139 then throw("insufficeient balance")
138140 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
139141 }
140142
141143
142144
143145 @Callable(i)
144146 func voteCommit (item,hash) = {
145147 let user = toBase58String(i.caller.bytes)
146148 let commits = getValueCommitsCount(item)
147149 let status = getValueItemStatus(item)
148150 if ((commits >= VOTERS))
149151 then throw("reached max num of voters")
150152 else if ((getValueCommit(item, user) != NONE))
151153 then throw("The user has participated already")
152154 else if ((getKeyItemSupplier(item) == NONE))
153155 then throw("item does not exist")
154156 else if (if ((status != NONE))
155157 then (status != VOTING)
156158 else false)
157159 then throw("voting is not possible")
158160 else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
159161 then REVEAL
160162 else VOTING)])
161163 }
162164
163165
164166
165167 @Callable(i)
166168 func voteReveal (item,vote,salt) = {
167169 let user = toBase58String(i.caller.bytes)
168170 let status = getValueItemStatus(item)
169171 let newVoteCount = (getValueVoteCount(item, vote) + 1)
170172 if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
171173 then throw("reveal data is not valid")
172174 else if ((VOTERS > getValueCommitsCount(item)))
173175 then throw("max num of voters hasn't reached yet")
174176 else if ((getValueReveal(item, user) != NONE))
175177 then throw("the user has already participated")
176178 else if (if ((status != VOTING))
177179 then (status != REVEAL)
178180 else false)
179181 then throw("Wrong status")
180182 else if (if ((vote != FEATURED))
181183 then (vote != DELISTED)
182184 else false)
183185 then throw("wrong vote")
184186 else if (if ((status == FEATURED))
185187 then true
186188 else (status == DELISTED))
187189 then throw("vote has finished")
188190 else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QORUM))
189191 then vote
190192 else REVEAL)])
191193 }
192194
193195
196+
197+@Callable(i)
198+func deposit () = {
199+ let pmt = extract(i.payment)
200+ if ((pmt.assetId != wavein))
201+ then throw("Sorry, only WAVWEIN for the moment")
202+ else {
203+ let currentKey = toBase58String(i.caller.bytes)
204+ let currentAmount = match getInteger(this, currentKey) {
205+ case a: Int =>
206+ a
207+ case _ =>
208+ 0
209+ }
210+ let newAmount = (currentAmount + pmt.amount)
211+ WriteSet([DataEntry(currentKey, newAmount)])
212+ }
213+ }
214+
215+

github/deemru/w8io/169f3d6 
40.39 ms