tx · Ha2tgRsLspMCkWY8pzCVhgWCdA88oWsuwewTRrEn1eCw

3MpEvJUwR46tdPKYd9mfoSeigDVDJzNDp8y:  -0.01000000 Waves

2021.07.07 10:41 [1602901] smart account 3MpEvJUwR46tdPKYd9mfoSeigDVDJzNDp8y > SELF 0.00000000 Waves

{ "type": 13, "id": "Ha2tgRsLspMCkWY8pzCVhgWCdA88oWsuwewTRrEn1eCw", "fee": 1000000, "feeAssetId": null, "timestamp": 1625643714445, "version": 2, "chainId": 84, "sender": "3MpEvJUwR46tdPKYd9mfoSeigDVDJzNDp8y", "senderPublicKey": "AjfGmMcujRDveyKiyrN2DkvnXKsxRmq4XFA9kZjb3iZh", "proofs": [ "3sxSswxNgEVhcD4NRYvoZNDX1YFJT6gjSmZUxbj4guGaSeQzBN3Ei5sksDacNxVpYsZZte4pomrr1iJGKHgBW6pb" ], "script": "base64:AAIFAAAAAAAAAi4IAhIFCgMIAQgSAwoBCBIAGgoKAmExEgROT05FGhQKAmEyEg5nZXROdW1iZXJCeUtleRoJCgJhMxIDa2V5GgkKAmE0EgNudW0aDQoCYTUSByRtYXRjaDAaBwoCYTYSAWEaEQoCYTcSC2dldFN0ckJ5S2V5GgkKAmE4EgNzdHIaFQoCYTkSD2dldEtleUl0ZW1QcmljZRoKCgJiMRIEaXRlbRoXCgJiMhIRZ2V0VmFsdWVJdGVtUHJpY2UaGwoCYjMSFWdldEtleVVzZXJJdGVtQ291bnRlchoKCgJiNBIEdXNlchodCgJiNRIXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIaEAoCYjYSCmdldEtleUl0ZW0aDgoCYjcSCHN1cHBsaWVyGgsKAmI4EgV0aXRsZRoUCgJiORIOZ2V0S2V5SXRlbURhdGEaGAoCYzESEmdldEtleUl0ZW1TdXBwbGllchoaCgJjMhIUZ2V0VmFsdWVJdGVtU3VwcGxpZXIaGwoCYzMSFWdldEtleUJhbGFuY2VTdXBwbGllchoNCgJjNBIHYWNjb3VudBodCgJjNRIXZ2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AAZgAAAAIFAAAAAmM3CAUAAAACZDEAAAAGYW1vdW50CQAAAgAAAAECAAAALlB1cmNoYXNlIGFtb3VudCBjYW5ub3QgYmUgbGVzcyB0aGFuIGl0ZW0gcHJpY2UDCQAAAAAAAAIFAAAAAmM5BQAAAAJhMQkAAAIAAAABAgAAABdTdXBwbGllciBkb2VzIG5vdCBleGlzdAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAmIzAAAAAgUAAAACZDIFAAAAAmIxCQAAZAAAAAIJAQAAAAJiNQAAAAIFAAAAAmQyBQAAAAJiMQAAAAAAAAAAAQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAmMzAAAAAQUAAAACYzkJAABkAAAAAgkBAAAAAmM1AAAAAQUAAAACYzkIBQAAAAJkMQAAAAZhbW91bnQFAAAAA25pbAAAAAJjNgEAAAAId2l0aGRyYXcAAAAABAAAAAJjOQkAAlgAAAABCAgFAAAAAmM2AAAABmNhbGxlcgAAAAVieXRlcwQAAAACZDMJAQAAAAJjNQAAAAEFAAAAAmM5AwkAAGcAAAACAAAAAAAAAAAABQAAAAJkMwkAAAIAAAABAgAAABNpbnN1ZmljaWVudCBiYWxhbmNlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAACYzMAAAABBQAAAAJjOQAAAAAAAAAAAAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAJjOQUAAAACZDMFAAAABHVuaXQFAAAAA25pbAAAAAAceWLv", "height": 1602901, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7weBWfw48N6XMNqLVfqE7ZhqPx1RBP4uq9gohrgceXnT Next: 4oTMuQVxA1bx7NVJJqZJZbSvvGB5WQEDsMWVjT2AJoLK Diff:
OldNewDifferences
8686 }
8787
8888
89+
90+@Callable(i)
91+func withdraw () = {
92+ let supplierAddress = toBase58String(i.caller.bytes)
93+ let balance = getValueBalanceSupplier(supplierAddress)
94+ if ((0 >= balance))
95+ then throw("insuficient balance")
96+ else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
97+ }
98+
99+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
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)
5959 func addItem (title,price,data) = {
6060 let supplierAddress = toBase58String(i.caller.bytes)
6161 let item = getKeyItem(supplierAddress, title)
6262 if ((0 >= price))
6363 then throw("Purchase amount cannot be less than item price")
6464 else if ((getValueItemSupplier(item) != NONE))
6565 then throw("an item already exists")
6666 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
6767 }
6868
6969
7070
7171 @Callable(i)
7272 func purchase (item) = {
7373 let pmt = i.payments[0]
7474 if (isDefined(pmt.assetId))
7575 then throw("WAVES ONLY HHEUAWHEUAS")
7676 else {
7777 let userAddress = toBase58String(i.caller.bytes)
7878 let price = getValueItemPrice(item)
7979 let supplierAddress = getValueItemSupplier(item)
8080 if ((price > pmt.amount))
8181 then throw("Purchase amount cannot be less than item price")
8282 else if ((supplierAddress == NONE))
8383 then throw("Supplier does not exist")
8484 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]
8585 }
8686 }
8787
8888
89+
90+@Callable(i)
91+func withdraw () = {
92+ let supplierAddress = toBase58String(i.caller.bytes)
93+ let balance = getValueBalanceSupplier(supplierAddress)
94+ if ((0 >= balance))
95+ then throw("insuficient balance")
96+ else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
97+ }
98+
99+

github/deemru/w8io/026f985 
33.49 ms