tx · 83rqZjx8yJHwJrjtTTstVTCiw8DT5CcKAmajPTifAaCA

3N5hvxB2quqLovdPCVjyXdJmJ73nmmYK35d:  -0.01400000 Waves

2019.08.30 16:37 [654059] smart account 3N5hvxB2quqLovdPCVjyXdJmJ73nmmYK35d > SELF 0.00000000 Waves

{ "type": 13, "id": "83rqZjx8yJHwJrjtTTstVTCiw8DT5CcKAmajPTifAaCA", "fee": 1400000, "feeAssetId": null, "timestamp": 1567172234000, "version": 1, "sender": "3N5hvxB2quqLovdPCVjyXdJmJ73nmmYK35d", "senderPublicKey": "6E6ogeeCpxu9SkEFhggJqUD7fCCQrW8rmAaCLNKzNiXK", "proofs": [ "64HhfeEG443EngfGW7rChoRpRzBck2ESkbZmkjetnA1U4TofFZjjKCW5k7XpfDrf4kkFU9xfqH1H6ZYnac4gP9G4" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfcHJpY2UBAAAAEWdldFZhbHVlSXRlbVByaWNlAAAAAQAAAARpdGVtCQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABCQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQ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IhPQAAAAIJAQAAABRnZXRWYWx1ZUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0FAAAABE5PTkUJAAACAAAAAQIAAAAYYW4gaXRlbSBpcyBhbHJlYWR5IGV4aXN0CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAPc3VwcGxpZXJBZGRyZXNzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQUAAAAEaXRlbQUAAAAFcHJpY2UJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEFAAAABGl0ZW0FAAAABGRhdGEFAAAAA25pbAAAAADTtFYR", "chainId": 84, "height": 654059, "spentComplexity": 0 } View: original | compacted Prev: ESWwA2eQLvmHAGEtUNvaDUM8Sztgt4VkNthKD558wRAn Next: CUTz7FtCymd35Mp9jfNT9NxA8a2T2A8WVDJdQgSa4nc1 Diff:
OldNewDifferences
5656
5757
5858 @Callable(i)
59+func withdraw () = {
60+ let supplierAddress = toBase58String(i.caller.bytes)
61+ let balance = getValueBalanceSupplier(supplierAddress)
62+ if ((0 >= balance))
63+ then throw("insufficient balance")
64+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
65+ }
66+
67+
68+
69+@Callable(i)
70+func purchase (item) = {
71+ let pmt = extract(i.payment)
72+ if (isDefined(pmt.assetId))
73+ then throw("WAVES tokens only at the moment")
74+ else {
75+ let userAddress = toBase58String(i.caller.bytes)
76+ let price = getValueItemPrice(item)
77+ let supplierAddress = getValueItemSupplier(item)
78+ if ((price > pmt.amount))
79+ then throw("purchase amount cannot be less than item price")
80+ else if ((pmt.amount > price))
81+ then throw("purchase amount cannot be higher than item price")
82+ else if ((supplierAddress == NONE))
83+ then throw("supplier does not exist")
84+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
85+ }
86+ }
87+
88+
89+
90+@Callable(i)
5991 func addItem (title,price,data) = {
6092 let supplierAddress = toBase58String(i.caller.bytes)
6193 let item = getKeyItem(supplierAddress, title)
6799 }
68100
69101
70-
71-@Callable(i)
72-func purchase () = {
73- let pmt = extract(i.payment)
74- if (isDefined(pmt.assetId))
75- then throw("can use Waves only at the moment")
76- else {
77- let customerAddress = toBase58String(i.caller.bytes)
78- let price = match getInteger(this, "item_A_coupon_price") {
79- case a: Int =>
80- a
81- case _ =>
82- 0
83- }
84- if ((price > pmt.amount))
85- then throw("purchase amount connot be less than item price")
86- else if ((pmt.amount > price))
87- then throw("purchase amount cannot be higher than item price")
88- else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)])
89- }
90- }
91-
92-
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getNumberByKey (key) = {
77 let num = match getInteger(this, key) {
88 case a: Int =>
99 a
1010 case _ =>
1111 0
1212 }
1313 num
1414 }
1515
1616
1717 func getStrByKey (key) = {
1818 let str = match getString(this, key) {
1919 case a: String =>
2020 a
2121 case _ =>
2222 NONE
2323 }
2424 str
2525 }
2626
2727
2828 func getKeyItemPrice (item) = (item + "_price")
2929
3030
3131 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3232
3333
3434 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3535
3636
3737 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
3838
3939
4040 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4141
4242
4343 func getKeyItemData (item) = (item + "_data")
4444
4545
4646 func getKeyItemSupplier (item) = (item + "_owner")
4747
4848
4949 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5050
5151
5252 func getKeyBalanceSupplier (account) = (account + "_balance")
5353
5454
5555 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5656
5757
5858 @Callable(i)
59+func withdraw () = {
60+ let supplierAddress = toBase58String(i.caller.bytes)
61+ let balance = getValueBalanceSupplier(supplierAddress)
62+ if ((0 >= balance))
63+ then throw("insufficient balance")
64+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
65+ }
66+
67+
68+
69+@Callable(i)
70+func purchase (item) = {
71+ let pmt = extract(i.payment)
72+ if (isDefined(pmt.assetId))
73+ then throw("WAVES tokens only at the moment")
74+ else {
75+ let userAddress = toBase58String(i.caller.bytes)
76+ let price = getValueItemPrice(item)
77+ let supplierAddress = getValueItemSupplier(item)
78+ if ((price > pmt.amount))
79+ then throw("purchase amount cannot be less than item price")
80+ else if ((pmt.amount > price))
81+ then throw("purchase amount cannot be higher than item price")
82+ else if ((supplierAddress == NONE))
83+ then throw("supplier does not exist")
84+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
85+ }
86+ }
87+
88+
89+
90+@Callable(i)
5991 func addItem (title,price,data) = {
6092 let supplierAddress = toBase58String(i.caller.bytes)
6193 let item = getKeyItem(supplierAddress, title)
6294 if ((0 >= price))
6395 then throw("purchase amount cannot be less than item price")
6496 else if ((getValueItemSupplier(item) != NONE))
6597 then throw("an item is already exist")
6698 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
6799 }
68100
69101
70-
71-@Callable(i)
72-func purchase () = {
73- let pmt = extract(i.payment)
74- if (isDefined(pmt.assetId))
75- then throw("can use Waves only at the moment")
76- else {
77- let customerAddress = toBase58String(i.caller.bytes)
78- let price = match getInteger(this, "item_A_coupon_price") {
79- case a: Int =>
80- a
81- case _ =>
82- 0
83- }
84- if ((price > pmt.amount))
85- then throw("purchase amount connot be less than item price")
86- else if ((pmt.amount > price))
87- then throw("purchase amount cannot be higher than item price")
88- else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)])
89- }
90- }
91-
92-

github/deemru/w8io/026f985 
24.37 ms