tx · Gc5tudrv7hneBBX1HK4h9t98WVwT8bbPxgSqWYjMPQjK 3MpBLQnAfhnyUMggAmVwDeUYqQukAGopQEk: -0.01000000 Waves 2022.03.18 10:17 [1969088] smart account 3MpBLQnAfhnyUMggAmVwDeUYqQukAGopQEk > SELF 0.00000000 Waves
{ "type": 13, "id": "Gc5tudrv7hneBBX1HK4h9t98WVwT8bbPxgSqWYjMPQjK", "fee": 1000000, "feeAssetId": null, "timestamp": 1647587854880, "version": 2, "chainId": 84, "sender": "3MpBLQnAfhnyUMggAmVwDeUYqQukAGopQEk", "senderPublicKey": "AJm3KtF3VKTiJ4UdDr3EG6ZoC2FgtGQvNsvJjn543RX8", "proofs": [ "3wTxQgu5mMfbrj1Ne63Vg33QP7A8bf7NN6gFzi3EY1WseGhfJWDbbN6KrNbrVLG6fXUM3gywozDiDJCWhkZ7bQpw" ], "script": "base64:AAIFAAAAAAAAABAIAhIFCgMIAQgSAwoBCBIAAAAAEAAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAABFnZXRWYWx1ZUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkBAAAADmdldE51bWJlck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AAAJDMgUAAAACQjMHBgMFAAAAAkMzBQAAAAJCMQcGAwUAAAACQzMFAAAAAkIyBwQAAAAHJG1hdGNoMAUAAAACdHgDAwUAAAACQUIGBQAAAAJBQwYFAAAAAkJDmhKuVw==", "height": 1969088, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# 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 APublicKey = base58'U3xmXuwXdeCeAJSQdhJaeqHPS5LPkxfxRfrAn9c2MQZ' | |
59 | + | ||
60 | + | let BPublicKey = base58'5FjFLEkXW5LRE1NFTJBTus2TxvCbmvw9mgnnDwhkfvpJ' | |
61 | + | ||
62 | + | let CPublicKey = base58'8DASziFWXkcTr7ZfP7Etr9y4iFWD3iNCmA9SgjfRmTZ4' | |
63 | + | ||
64 | + | @Callable(i) | |
65 | + | func addItem (title,price,data) = { | |
66 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
67 | + | let item = getKeyItem(supplierAddress, title) | |
68 | + | if ((0 >= price)) | |
69 | + | then throw("purchase amount cannot be less than item price") | |
70 | + | else if ((getValueItemSupplier(item) != NONE)) | |
71 | + | then throw("an item is already exist") | |
72 | + | else $Tuple2([StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)], unit) | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func purchase (item) = { | |
79 | + | let pmt = i.payments[0] | |
80 | + | if (isDefined(pmt.assetId)) | |
81 | + | then throw("can use WAVES only at the moment") | |
82 | + | else { | |
83 | + | let userAddress = toBase58String(i.caller.bytes) | |
84 | + | let price = getValueItemPrice(item) | |
85 | + | let supplierAddress = getValueItemSupplier(item) | |
86 | + | if ((price > pmt.amount)) | |
87 | + | then throw("purchase amount cannot be less than item price") | |
88 | + | else if ((pmt.amount > price)) | |
89 | + | then throw("purchase amount cannot be higher than item price") | |
90 | + | else if ((supplierAddress == NONE)) | |
91 | + | then throw("supplier does not exist") | |
92 | + | else $Tuple2([IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))], unit) | |
93 | + | } | |
94 | + | } | |
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | @Callable(i) | |
99 | + | func withdraw () = { | |
100 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
101 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
102 | + | if ((0 >= balance)) | |
103 | + | then throw("insufficient balance") | |
104 | + | else $Tuple2([IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)], unit) | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | @Verifier(tx) | |
109 | + | func verify () = { | |
110 | + | let A1 = sigVerify(tx.bodyBytes, tx.proofs[0], APublicKey) | |
111 | + | let A2 = sigVerify(tx.bodyBytes, tx.proofs[1], APublicKey) | |
112 | + | let A3 = sigVerify(tx.bodyBytes, tx.proofs[2], APublicKey) | |
113 | + | let B1 = sigVerify(tx.bodyBytes, tx.proofs[0], BPublicKey) | |
114 | + | let B2 = sigVerify(tx.bodyBytes, tx.proofs[1], BPublicKey) | |
115 | + | let B3 = sigVerify(tx.bodyBytes, tx.proofs[2], BPublicKey) | |
116 | + | let C1 = sigVerify(tx.bodyBytes, tx.proofs[0], CPublicKey) | |
117 | + | let C2 = sigVerify(tx.bodyBytes, tx.proofs[1], CPublicKey) | |
118 | + | let C3 = sigVerify(tx.bodyBytes, tx.proofs[2], CPublicKey) | |
119 | + | let AB = if (if (if (if (if (if (A1) | |
120 | + | then B2 | |
121 | + | else false) | |
122 | + | then true | |
123 | + | else if (A1) | |
124 | + | then B3 | |
125 | + | else false) | |
126 | + | then true | |
127 | + | else if (A2) | |
128 | + | then B1 | |
129 | + | else false) | |
130 | + | then true | |
131 | + | else if (A2) | |
132 | + | then B3 | |
133 | + | else false) | |
134 | + | then true | |
135 | + | else if (A3) | |
136 | + | then B1 | |
137 | + | else false) | |
138 | + | then true | |
139 | + | else if (A3) | |
140 | + | then B2 | |
141 | + | else false | |
142 | + | let AC = if (if (if (if (if (if (A1) | |
143 | + | then C2 | |
144 | + | else false) | |
145 | + | then true | |
146 | + | else if (A1) | |
147 | + | then C3 | |
148 | + | else false) | |
149 | + | then true | |
150 | + | else if (A2) | |
151 | + | then C1 | |
152 | + | else false) | |
153 | + | then true | |
154 | + | else if (A2) | |
155 | + | then C3 | |
156 | + | else false) | |
157 | + | then true | |
158 | + | else if (A3) | |
159 | + | then C1 | |
160 | + | else false) | |
161 | + | then true | |
162 | + | else if (A3) | |
163 | + | then C2 | |
164 | + | else false | |
165 | + | let BC = if (if (if (if (if (if (C1) | |
166 | + | then B2 | |
167 | + | else false) | |
168 | + | then true | |
169 | + | else if (C1) | |
170 | + | then B3 | |
171 | + | else false) | |
172 | + | then true | |
173 | + | else if (C2) | |
174 | + | then B1 | |
175 | + | else false) | |
176 | + | then true | |
177 | + | else if (C2) | |
178 | + | then B3 | |
179 | + | else false) | |
180 | + | then true | |
181 | + | else if (C3) | |
182 | + | then B1 | |
183 | + | else false) | |
184 | + | then true | |
185 | + | else if (C3) | |
186 | + | then B2 | |
187 | + | else false | |
188 | + | match tx { | |
189 | + | case _ => | |
190 | + | if (if (AB) | |
191 | + | then true | |
192 | + | else AC) | |
193 | + | then true | |
194 | + | else BC | |
195 | + | } | |
196 | + | } | |
197 | + |
github/deemru/w8io/026f985 17.03 ms ◑