tx · J1o7LrnUANvJGJ2T5vatrjaWpWzJQ5irT2Q3dhDQP2rd 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR: -0.01000000 Waves 2019.07.14 02:38 [584647] smart account 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR > SELF 0.00000000 Waves
{ "type": 13, "id": "J1o7LrnUANvJGJ2T5vatrjaWpWzJQ5irT2Q3dhDQP2rd", "fee": 1000000, "feeAssetId": null, "timestamp": 1563061105523, "version": 1, "sender": "3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR", "senderPublicKey": "Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV", "proofs": [ "ReBVUoJ25z7yX3nN4K9MGimzo6p6PHnh3PdgByZQQR3Q8HzeaQwHzf1M47Mv8ikCXHMaBcTaZx1rR6Z94ZnKeLc" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAA5vd25lclB1YmxpY0tleQEAAAAgAnfP9tCFuj2k2BUY5PW9DVGxrCHBHKJwugv8WyiaGXIAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0V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AAAAFkBQAAAAckbWF0Y2gwBgdaPAaO", "chainId": 84, "height": 584647, "spentComplexity": 0 } View: original | compacted Prev: none Next: 9zkvzo8pJgcQaSPVWyMXXr2y8BDei9NygdLaKajvQJLN Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let ownerPublicKey = base58'Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV' | |
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 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
61 | + | ||
62 | + | ||
63 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
64 | + | ||
65 | + | ||
66 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
67 | + | ||
68 | + | ||
69 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
70 | + | ||
71 | + | ||
72 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
73 | + | ||
74 | + | ||
75 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
76 | + | ||
77 | + | ||
78 | + | func getKeyItemStatus (item) = (item + "_status") | |
79 | + | ||
80 | + | ||
81 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
82 | + | ||
83 | + | ||
84 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
85 | + | ||
86 | + | ||
87 | + | @Callable(i) | |
88 | + | func purchase (item) = { | |
89 | + | let pmt = extract(i.payment) | |
90 | + | if (isDefined(pmt.assetId)) | |
91 | + | then throw("can use WAVES only at the moment") | |
92 | + | else { | |
93 | + | let customerAddress = toBase58String(i.caller.bytes) | |
94 | + | let price = match getInteger(this, "item_A_coupon_price") { | |
95 | + | case a: Int => | |
96 | + | a | |
97 | + | case _ => | |
98 | + | 0 | |
99 | + | } | |
100 | + | if ((price > pmt.amount)) | |
101 | + | then throw("purchase amount cannot be less than item price") | |
102 | + | else if ((pmt.amount > price)) | |
103 | + | then throw("purchase amount cannot be higher than item price") | |
104 | + | else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)]) | |
105 | + | } | |
106 | + | } | |
107 | + | ||
108 | + | ||
109 | + | ||
110 | + | @Callable(i) | |
111 | + | func addItem (title,price,data) = { | |
112 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
113 | + | let item = getKeyItem(supplierAddress, title) | |
114 | + | if ((0 >= price)) | |
115 | + | then throw("purchase amount cannot be less than item price") | |
116 | + | else if ((getValueItemSupplier(item) != NONE)) | |
117 | + | then throw("an item is already exist") | |
118 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
119 | + | } | |
120 | + | ||
121 | + | ||
122 | + | @Verifier(tx) | |
123 | + | func verify () = match tx { | |
124 | + | case d: SetScriptTransaction => | |
125 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
126 | + | case d: DataTransaction => | |
127 | + | true | |
128 | + | case _ => | |
129 | + | false | |
130 | + | } | |
131 | + |
github/deemru/w8io/026f985 15.20 ms ◑