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