tx · 7sDWF6wtE9jAVLFfjAGHZDH8dLpET9BMdkGQWB5b9UZJ

3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq:  -0.01400000 Waves

2019.06.22 21:03 [553587] smart account 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq > SELF 0.00000000 Waves

{ "type": 13, "id": "7sDWF6wtE9jAVLFfjAGHZDH8dLpET9BMdkGQWB5b9UZJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1561226673118, "version": 1, "sender": "3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq", "senderPublicKey": "4fygXNNAjU52sT9N6uq4o9Ck8G75e94ukktN3pd4VxVo", "proofs": [ "nwNi1PvHRc7V8bK7oRGyrYnfffQGB9JMJxLFsu1A4g9RkQJyCPFwP6aYuPeBXhxYmuP7nRicxMr3MrhGRPzEUJ4" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARp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S2V5QmFsYW5jZVN1cHBsaWVyAAAAAQUAAAAHc3VwcGFkZAAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAHc3VwcGFkZAUAAAADYmFsBQAAAAR1bml0BQAAAANuaWwAAAAACxv0qg==", "chainId": 84, "height": 553587, "spentComplexity": 0 } View: original | compacted Prev: CWrLUufHmLNSbDeiEJXyBgDDFcBNkrBwR9jRnzUmkLhB Next: HmBzj946MzeuYTqBQTjWtVqvSPJ1gvCdHhuwFRTqpsaS Diff:
OldNewDifferences
8686 }
8787
8888
89+
90+@Callable(i)
91+func withdraw () = {
92+ let suppadd = toBase58String(i.caller.bytes)
93+ let bal = getValueBalanceSupplier(suppadd)
94+ if ((0 >= bal))
95+ then throw("Insufficient Balance")
96+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(suppadd), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppadd), bal, unit)]))
97+ }
98+
99+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getKeyItemPrice (item) = (item + "_price")
77
88
99 func getNumberByKey (key) = {
1010 let num = match getInteger(this, key) {
1111 case a: Int =>
1212 a
1313 case _ =>
1414 0
1515 }
1616 num
1717 }
1818
1919
2020 func getStrByKey (key) = {
2121 let str = match getString(this, key) {
2222 case a: String =>
2323 a
2424 case _ =>
2525 NONE
2626 }
2727 str
2828 }
2929
3030
3131 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3232
3333
3434 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
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)
5959 func additem (title,price,data) = {
6060 let suppad = toBase58String(i.caller.bytes)
6161 let item = getKeyItem(suppad, title)
6262 if ((0 >= price))
6363 then throw("purchase amount cannot be less than 0 or 0")
6464 else if ((getValueItemSupplier(item) != NONE))
6565 then throw("an item already exists")
6666 else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
6767 }
6868
6969
7070
7171 @Callable(i)
7272 func purchase (item) = {
7373 let pmt = extract(i.payment)
7474 if (isDefined(pmt.assetId))
7575 then throw("Can use Waves only at the moment")
7676 else {
7777 let customerAddress = toBase58String(i.caller.bytes)
7878 let price = getValueItemPrice(item)
7979 let supadd = getValueItemSupplier(item)
8080 if ((price > pmt.amount))
8181 then throw("purchase amount cannot be less than item price ")
8282 else if ((pmt.amount > price))
8383 then throw("purchase amount cannot be higher than item price")
8484 else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, item), (getValueUserItemCounter(customerAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supadd), (getValueBalanceSupplier(supadd) + pmt.amount))])
8585 }
8686 }
8787
8888
89+
90+@Callable(i)
91+func withdraw () = {
92+ let suppadd = toBase58String(i.caller.bytes)
93+ let bal = getValueBalanceSupplier(suppadd)
94+ if ((0 >= bal))
95+ then throw("Insufficient Balance")
96+ else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(suppadd), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppadd), bal, unit)]))
97+ }
98+
99+

github/deemru/w8io/026f985 
24.59 ms