tx · 9gsbUcZFE1WLZkbc8PV67bjNPLDX83BoN5EEVC4k6ipu

3NCh8zGspYnijzFDCn8ymCLkbyjyNespCyw:  -0.01400000 Waves

2019.08.19 18:12 [638198] smart account 3NCh8zGspYnijzFDCn8ymCLkbyjyNespCyw > SELF 0.00000000 Waves

{ "type": 13, "id": "9gsbUcZFE1WLZkbc8PV67bjNPLDX83BoN5EEVC4k6ipu", "fee": 1400000, "feeAssetId": null, "timestamp": 1566227511109, "version": 1, "sender": "3NCh8zGspYnijzFDCn8ymCLkbyjyNespCyw", "senderPublicKey": "7ysuj2fDbpxe99K1XwoPXgZzddqsEM4XpihWxn1brV58", "proofs": [ "2htyPvFhn5zRTQPpKN6agkcaUypLzvAuijRVMhBX1mF3ZxAdGBmpvaC4wE7ixu79XAeR7fbdr2EzSjMDyPwBPWtL" ], "script": "base64:AwZd0cYf", "chainId": 84, "height": 638198, "spentComplexity": 0 } View: original | compacted Prev: BW2RZ4XSt6CTzvwJxjLwua94dFVvoXE83m2RrgbJqBxX Next: DKVPu9Jq57kgWkHzqqJAvpTDwMGpMdbNDvBUExtQwHe8 Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
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-@Callable(i)
59-func purchase (B) = {
60- let pmt = extract(i.payment)
61- if (isDefined(pmt.assetId))
62- then throw("can use WAVES only at the moment")
63- else {
64- let customerAddress = toBase58String(i.caller.bytes)
65- let price = match getInteger(this, (("item_" + B) + "_coupon_price")) {
66- case a: Int =>
67- a
68- case _ =>
69- 0
70- }
71- if ((price > pmt.amount))
72- then throw("purchase amount cannot be less than item price ")
73- else if ((pmt.amount > price))
74- then throw("purchase amount cannot be higher than item price")
75- else WriteSet([DataEntry(((("status:purchase_item_" + B) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + B) + "_customer_") + customerAddress), price)])
76- }
77- }
78-
79-
80-
81-@Callable(i)
82-func addItem (title,price,data) = {
83- let supplierAddress = toBase58String(i.caller.bytes)
84- let item = getKeyItem(supplierAddress, title)
85- if ((0 >= price))
86- then throw("purchase amount cannot be less then item price")
87- else if ((getValueItemSupplier(item) != NONE))
88- then throw("an item is already exist")
89- else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
90- }
91-
92-
2+{-# CONTENT_TYPE EXPRESSION #-}
3+true

github/deemru/w8io/3ef1775 
33.80 ms