tx · 38fps9uTha96RKEx23Zt9XdugwGiFHwQqRW9wwyewrsN 3MzWo7E8tghhwcfqLZg24SHkzwNwqPYughx: -0.01000000 Waves 2022.03.18 09:17 [1969027] smart account 3MzWo7E8tghhwcfqLZg24SHkzwNwqPYughx > SELF 0.00000000 Waves
{ "type": 13, "id": "38fps9uTha96RKEx23Zt9XdugwGiFHwQqRW9wwyewrsN", "fee": 1000000, "feeAssetId": null, "timestamp": 1647584231864, "version": 2, "chainId": 84, "sender": "3MzWo7E8tghhwcfqLZg24SHkzwNwqPYughx", "senderPublicKey": "U3xmXuwXdeCeAJSQdhJaeqHPS5LPkxfxRfrAn9c2MQZ", "proofs": [ "3amZvu1eP5rEE7hUTh6VaUTns15Citr8o2epY7JWVLjSjsC6DwxGJHi5WeCWFGELkswAatkGyiTqJjxWQcGLkmB7" ], "script": "base64:AAIFAAAAAAAAAA4IAhIFCgMIAQgSAwoBCAAAABAAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABAAAABGl0ZW0JAQAAAA5nZXROdW1iZXJCeUtleQAAAAEJAQAAAA9nZX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cm9vZnMAAAAAAAAAAAIFAAAACkNQdWJsaWNLZXkEAAAAAkFCAwMDAwMDBQAAAAJBMQUAAAACQjIHBgMFAAAAAkExBQAAAAJCMwcGAwUAAAACQTIFAAAAAkIxBwYDBQAAAAJBMgUAAAACQjMHBgMFAAAAAkEzBQAAAAJCMQcGAwUAAAACQTMFAAAAAkIyBwQAAAACQUMDAwMDAwMFAAAAAkExBQAAAAJDMgcGAwUAAAACQTEFAAAAAkMzBwYDBQAAAAJBMgUAAAACQzEHBgMFAAAAAkEyBQAAAAJDMwcGAwUAAAACQTMFAAAAAkMxBwYDBQAAAAJBMwUAAAACQzIHBAAAAAJCQwMDAwMDAwUAAAACQzEFAAAAAkIyBwYDBQAAAAJDMQUAAAACQjMHBgMFAAAAAkMyBQAAAAJCMQcGAwUAAAACQzIFAAAAAkIzBwYDBQAAAAJDMwUAAAACQjEHBgMFAAAAAkMzBQAAAAJCMgcEAAAAByRtYXRjaDAFAAAAAnR4AwMFAAAAAkFCBgUAAAACQUMGBQAAAAJCQ56u2G8=", "height": 1969027, "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 | + | @Verifier(tx) | |
98 | + | func verify () = { | |
99 | + | let A1 = sigVerify(tx.bodyBytes, tx.proofs[0], APublicKey) | |
100 | + | let A2 = sigVerify(tx.bodyBytes, tx.proofs[1], APublicKey) | |
101 | + | let A3 = sigVerify(tx.bodyBytes, tx.proofs[2], APublicKey) | |
102 | + | let B1 = sigVerify(tx.bodyBytes, tx.proofs[0], BPublicKey) | |
103 | + | let B2 = sigVerify(tx.bodyBytes, tx.proofs[1], BPublicKey) | |
104 | + | let B3 = sigVerify(tx.bodyBytes, tx.proofs[2], BPublicKey) | |
105 | + | let C1 = sigVerify(tx.bodyBytes, tx.proofs[0], CPublicKey) | |
106 | + | let C2 = sigVerify(tx.bodyBytes, tx.proofs[1], CPublicKey) | |
107 | + | let C3 = sigVerify(tx.bodyBytes, tx.proofs[2], CPublicKey) | |
108 | + | let AB = if (if (if (if (if (if (A1) | |
109 | + | then B2 | |
110 | + | else false) | |
111 | + | then true | |
112 | + | else if (A1) | |
113 | + | then B3 | |
114 | + | else false) | |
115 | + | then true | |
116 | + | else if (A2) | |
117 | + | then B1 | |
118 | + | else false) | |
119 | + | then true | |
120 | + | else if (A2) | |
121 | + | then B3 | |
122 | + | else false) | |
123 | + | then true | |
124 | + | else if (A3) | |
125 | + | then B1 | |
126 | + | else false) | |
127 | + | then true | |
128 | + | else if (A3) | |
129 | + | then B2 | |
130 | + | else false | |
131 | + | let AC = if (if (if (if (if (if (A1) | |
132 | + | then C2 | |
133 | + | else false) | |
134 | + | then true | |
135 | + | else if (A1) | |
136 | + | then C3 | |
137 | + | else false) | |
138 | + | then true | |
139 | + | else if (A2) | |
140 | + | then C1 | |
141 | + | else false) | |
142 | + | then true | |
143 | + | else if (A2) | |
144 | + | then C3 | |
145 | + | else false) | |
146 | + | then true | |
147 | + | else if (A3) | |
148 | + | then C1 | |
149 | + | else false) | |
150 | + | then true | |
151 | + | else if (A3) | |
152 | + | then C2 | |
153 | + | else false | |
154 | + | let BC = if (if (if (if (if (if (C1) | |
155 | + | then B2 | |
156 | + | else false) | |
157 | + | then true | |
158 | + | else if (C1) | |
159 | + | then B3 | |
160 | + | else false) | |
161 | + | then true | |
162 | + | else if (C2) | |
163 | + | then B1 | |
164 | + | else false) | |
165 | + | then true | |
166 | + | else if (C2) | |
167 | + | then B3 | |
168 | + | else false) | |
169 | + | then true | |
170 | + | else if (C3) | |
171 | + | then B1 | |
172 | + | else false) | |
173 | + | then true | |
174 | + | else if (C3) | |
175 | + | then B2 | |
176 | + | else false | |
177 | + | match tx { | |
178 | + | case _ => | |
179 | + | if (if (AB) | |
180 | + | then true | |
181 | + | else AC) | |
182 | + | then true | |
183 | + | else BC | |
184 | + | } | |
185 | + | } | |
186 | + |
github/deemru/w8io/026f985 16.09 ms ◑