tx · 5y1oCkK3imL5H8cEMoC3Sc3Fqdd8oCxCyLP6VAMr1SrX 3NBY19sy9tBYtV3Xf15DrMAgM555oi7S4pP: -0.05000000 Waves 2020.02.07 21:39 [889172] smart account 3NBY19sy9tBYtV3Xf15DrMAgM555oi7S4pP > SELF 0.00000000 Waves
{ "type": 13, "id": "5y1oCkK3imL5H8cEMoC3Sc3Fqdd8oCxCyLP6VAMr1SrX", "fee": 5000000, "feeAssetId": null, "timestamp": 1581100760971, "version": 1, "sender": "3NBY19sy9tBYtV3Xf15DrMAgM555oi7S4pP", "senderPublicKey": "FUWhBBCT8RpLYi4Ak1vzBzSaazgezQHqHdLScfYtbYNu", "proofs": [ "27dChn2UvSHRi94eWbNFTsvpM2SoVi8QPXswKE8rNkoLGxNhjCycQGyEArTHTZpJwRaFZ79w1XQexLhEbGCsQvk3" ], "script": "base64:AAIDAAAAAAAAAAsIARIAEgUKAwgBCAAAAA4AAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABAAAABGl0ZW0JAQAAAA5nZXROdW1iZXJCeUtleQAAAAEJAQAAAA9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AAAAckbWF0Y2gwBgceI6TE", "chainId": 84, "height": 889172, "spentComplexity": 0 } View: original | compacted Prev: 5stZyQYToEcRjWSnLBrCg5HLp2PLmR7rkdzLsjSdeqSq Next: none Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
58 | + | let ownerPublicKey = base58'AEPkVhxxwDcFuxp5ykhU7hErZWKFukRePVvcsTpUJm1L' | |
59 | + | ||
58 | 60 | @Callable(i) | |
59 | 61 | func purchase () = { | |
60 | 62 | let pmt = extract(i.payment) | |
90 | 92 | } | |
91 | 93 | ||
92 | 94 | ||
95 | + | @Verifier(tx) | |
96 | + | func verify () = match tx { | |
97 | + | case d: SetScriptTransaction => | |
98 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
99 | + | case d: DataTransaction => | |
100 | + | true | |
101 | + | case _ => | |
102 | + | false | |
103 | + | } | |
104 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | func getNumberByKey (key) = { | |
7 | 7 | let num = match getInteger(this, key) { | |
8 | 8 | case a: Int => | |
9 | 9 | a | |
10 | 10 | case _ => | |
11 | 11 | 0 | |
12 | 12 | } | |
13 | 13 | num | |
14 | 14 | } | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStrByKey (key) = { | |
18 | 18 | let str = match getString(this, key) { | |
19 | 19 | case a: String => | |
20 | 20 | a | |
21 | 21 | case _ => | |
22 | 22 | NONE | |
23 | 23 | } | |
24 | 24 | str | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getKeyItemPrice (item) = (item + "_price") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getKeyItemData (item) = (item + "_data") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
58 | + | let ownerPublicKey = base58'AEPkVhxxwDcFuxp5ykhU7hErZWKFukRePVvcsTpUJm1L' | |
59 | + | ||
58 | 60 | @Callable(i) | |
59 | 61 | func purchase () = { | |
60 | 62 | let pmt = extract(i.payment) | |
61 | 63 | if (isDefined(pmt.assetId)) | |
62 | 64 | then throw("can use WAVES only at the moment") | |
63 | 65 | else { | |
64 | 66 | let customerAddress = toBase58String(i.caller.bytes) | |
65 | 67 | let price = match getInteger(this, "item_A_coupon_price") { | |
66 | 68 | case a: Int => | |
67 | 69 | a | |
68 | 70 | case _ => | |
69 | 71 | 0 | |
70 | 72 | } | |
71 | 73 | if ((price > pmt.amount)) | |
72 | 74 | then throw("purchase amount cannot be less than item price") | |
73 | 75 | else if ((pmt.amount > price)) | |
74 | 76 | then throw("purchase amount cannot be higher than item price") | |
75 | 77 | else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)]) | |
76 | 78 | } | |
77 | 79 | } | |
78 | 80 | ||
79 | 81 | ||
80 | 82 | ||
81 | 83 | @Callable(i) | |
82 | 84 | func addItem (title,price,data) = { | |
83 | 85 | let supplierAddress = toBase58String(i.caller.bytes) | |
84 | 86 | let item = getKeyItem(supplierAddress, title) | |
85 | 87 | if ((0 >= price)) | |
86 | 88 | then throw("purchase amount cannot be less than item price") | |
87 | 89 | else if ((getValueItemSupplier(item) != NONE)) | |
88 | 90 | then throw("an item is already exist") | |
89 | 91 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
90 | 92 | } | |
91 | 93 | ||
92 | 94 | ||
95 | + | @Verifier(tx) | |
96 | + | func verify () = match tx { | |
97 | + | case d: SetScriptTransaction => | |
98 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
99 | + | case d: DataTransaction => | |
100 | + | true | |
101 | + | case _ => | |
102 | + | false | |
103 | + | } | |
104 | + |
github/deemru/w8io/169f3d6 33.08 ms ◑