tx · 5Aoq76tGWqzsEqxcGnjCgH7a69CvCm7jyV6jF6KXGYGa

3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D:  -0.01400000 Waves

2019.06.22 17:13 [553358] smart account 3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D > SELF 0.00000000 Waves

{ "type": 13, "id": "5Aoq76tGWqzsEqxcGnjCgH7a69CvCm7jyV6jF6KXGYGa", "fee": 1400000, "feeAssetId": null, "timestamp": 1561212871599, "version": 1, "sender": "3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D", "senderPublicKey": "BJRaSW2saRv7CcFs3mSYpaVFQSFpZq9rGKnCcRKuKgWv", "proofs": [ "4M3W1NAAB2FZS8Pyr7L8T2Hrx7mppxtNCRjpzgoUPJvD6C2bRPVABLqBt4Xf4wfZSjtnmvJkrFyyMZPCvaneBxY2" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAApnZXRLZXlJdGVtAAAAAgAAAAhzdXBwbGllcgAAAAV0aXRsZQkAASwAAAACAgAAAAVpdGVtXwkAAlgAAAABCQAB9wAAAAEJAAGbAAAAAQkAASwAAAACBQAAAAhzdXBwbGllcgUAAAAFdGl0bGUBAAAAEmdldEtleUl0ZW1TdXBwbGllcgAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfb3duZXIBAAAAFWdldEtleUJhbGFuY2VTdXBwbGllcgAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAhfYmFsYW5jZQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAAOZ2V0S2V5SXRlbURhdGEAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAFX2RhdGEBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAE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jZQkBAAAAF2dldFZhbHVlQmFsYW5jZVN1cHBsaWVyAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzAwkAAGcAAAACAAAAAAAAAAAABQAAAAdiYWxhbmNlCQAAAgAAAAECAAAAFGluc3VmZmljaWVudCBiYWxhbmNlCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFWdldEtleUJhbGFuY2VTdXBwbGllcgAAAAEFAAAAD3N1cHBsaWVyQWRkcmVzcwAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzBQAAAAdiYWxhbmNlBQAAAAR1bml0BQAAAANuaWwAAAAAwSzENA==", "chainId": 84, "height": 553358, "spentComplexity": 0 } View: original | compacted Prev: EKC61cF24UvhESRWABKAvwmG1BiZ1EMjb7zDrUh39kdc Next: C61ebeiM7iWGYJUJUebHmLWEMcbNizcbDkpqYELujFpe Diff:
OldNewDifferences
111111 }
112112
113113
114+
115+@Callable(i)
116+func withdraw () = {
117+ let supplierAddress = toBase58String(i.caller.bytes)
118+ let balance = getValueBalanceSupplier(supplierAddress)
119+ if ((0 >= balance))
120+ then throw("insufficient balance")
121+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
122+ }
123+
124+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
77
88
99 func getKeyItemSupplier (item) = (item + "_owner")
1010
1111
1212 func getKeyBalanceSupplier (item) = (item + "_balance")
1313
1414
1515 func getKeyItemPrice (item) = (item + "_price")
1616
1717
1818 func getKeyItemData (item) = (item + "_data")
1919
2020
2121 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
2222
2323
2424 func getStrByKey (key) = {
2525 let str = match getString(this, key) {
2626 case a: String =>
2727 a
2828 case _ =>
2929 NONE
3030 }
3131 str
3232 }
3333
3434
3535 func getNumberByKey (key) = {
3636 let num = match getInteger(this, key) {
3737 case a: Int =>
3838 a
3939 case _ =>
4040 0
4141 }
4242 num
4343 }
4444
4545
4646 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
4747
4848
4949 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
5050
5151
5252 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
5353
5454
5555 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5656
5757
5858 @Callable(i)
5959 func purchaseOld (type) = {
6060 let pmt = extract(i.payment)
6161 if (isDefined(pmt.assetId))
6262 then throw("can use WAVES only at the moment")
6363 else {
6464 let customerAddress = toBase58String(i.caller.bytes)
6565 let price = match getInteger(this, (("item_" + type) + "_coupon_price")) {
6666 case a: Int =>
6767 a
6868 case _ =>
6969 0
7070 }
7171 if ((price > pmt.amount))
7272 then throw("purschase amount cannot be less than item price")
7373 else if ((pmt.amount > price))
7474 then throw("purchase amount cannot be higher than item price")
7575 else WriteSet([DataEntry(((("status:purchase_item_" + type) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + type) + "_customer_") + customerAddress), price)])
7676 }
7777 }
7878
7979
8080
8181 @Callable(i)
8282 func addItem (title,price,data) = {
8383 let supplierAddress = toBase58String(i.caller.bytes)
8484 let item = getKeyItem(supplierAddress, title)
8585 if ((0 >= price))
8686 then throw("purchase amount cannot be less than item price")
8787 else if ((getValueItemSupplier(item) != NONE))
8888 then throw("an items is already exist")
8989 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
9090 }
9191
9292
9393
9494 @Callable(i)
9595 func purchase (item) = {
9696 let pmt = extract(i.payment)
9797 if (isDefined(pmt.assetId))
9898 then throw("WAVES tokens only at the moment")
9999 else {
100100 let userAddress = toBase58String(i.caller.bytes)
101101 let price = getValueItemPrice(item)
102102 let supplierAddress = getValueItemSupplier(item)
103103 if ((price > pmt.amount))
104104 then throw("purchase amount cannot be less than item price")
105105 else if ((pmt.amount > price))
106106 then throw("purchase amount cannot be higher than item price")
107107 else if ((supplierAddress == NONE))
108108 then throw("supplier does not exist")
109109 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
110110 }
111111 }
112112
113113
114+
115+@Callable(i)
116+func withdraw () = {
117+ let supplierAddress = toBase58String(i.caller.bytes)
118+ let balance = getValueBalanceSupplier(supplierAddress)
119+ if ((0 >= balance))
120+ then throw("insufficient balance")
121+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
122+ }
123+
124+

github/deemru/w8io/026f985 
33.12 ms