tx · zwakKpemf7yZ1ytwhjtfUxJLTAeL44dNBzYchFU5MHp

3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c:  -0.01000000 Waves

2021.07.07 10:31 [1602891] smart account 3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c > SELF 0.00000000 Waves

{ "type": 13, "id": "zwakKpemf7yZ1ytwhjtfUxJLTAeL44dNBzYchFU5MHp", "fee": 1000000, "feeAssetId": null, "timestamp": 1625643084133, "version": 2, "chainId": 84, "sender": "3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c", "senderPublicKey": "9dJbLdKrkcPAEacPHvgivaqbGgimy4WN2MRrE6XXWFQu", "proofs": [ "5mC4F5CCxCZPtJWagnYyc3HEa6EPdRX54RoZaLbHppwoZNr8izy8DzRdbegR43emakWwPnz9x8EyMdpgMBGacmBi" ], "script": "base64:AAIFAAAAAAAAAi4IAhIFCgMIAQgSAwoBCBIAGgoKAmExEgROT05FGhQKAmEyEg5nZXROdW1iZXJCeUtleRoJCgJhMxIDa2V5GgkKAmE0EgNudW0aDQoCYTUSByRtYXRjaDAaBwoCYTYSAWEaEQoCYTcSC2dldFN0ckJ5S2V5GgkKAmE4EgNzdHIaFQoCYTkSD2dldEtleUl0ZW1QcmljZRoKCgJiMRIEaXRlbRoXCgJiMhIRZ2V0VmFsdWVJdGVtUHJpY2UaGwoCYjMSFWdldEtleVVzZXJJdGVtQ291bnRlchoKCgJiNBIEdXNlchodCgJiNRIXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIaEAoCYjYSCmdldEtleUl0ZW0aDgoCYjcSCHN1cHBsaWVyGgsKAmI4EgV0aXRsZRoUCgJiORIOZ2V0S2V5SXRlbURhdGEaGAoCYzESEmdldEtleUl0ZW1TdXBwbGllchoaCgJjMhIUZ2V0VmFsdWVJdGVtU3VwcGxpZXIaGwoCYzMSFWdldEtleUJhbGFuY2VTdXBwbGllchoNCgJjNBIHYWNjb3VudBodCgJjNRIXZ2V0VmFsdWV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FAAAAAmM3CAUAAAACZDEAAAAGYW1vdW50CQAAAgAAAAECAAAALlB1cmNoYXNlIGFtb3VudCBjYW5ub3QgYmUgbGVzcyB0aGFuIGl0ZW0gcHJpY2UDCQAAAAAAAAIFAAAAAmM5BQAAAAJhMQkAAAIAAAABAgAAABdTdXBwbGllciBkb2VzIG5vdCBleGlzdAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAmIzAAAAAgUAAAACZDIFAAAAAmIxCQAAZAAAAAIJAQAAAAJiNQAAAAIFAAAAAmQyBQAAAAJiMQAAAAAAAAAAAQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAmMzAAAAAQUAAAACYzkJAABkAAAAAgkBAAAAAmM1AAAAAQUAAAACYzkIBQAAAAJkMQAAAAZhbW91bnQFAAAAA25pbAAAAAJjNgEAAAAId2l0aGRyYXcAAAAABAAAAAJjOQkAAlgAAAABCAgFAAAAAmM2AAAABmNhbGxlcgAAAAVieXRlcwQAAAACZDMJAQAAAAJjNQAAAAEFAAAAAmM5AwkAAGcAAAACAAAAAAAAAAAABQAAAAJkMwkAAAIAAAABAgAAABNpbnN1ZmljaWVudCBiYWxhbmNlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAACYzMAAAABBQAAAAJjOQAAAAAAAAAAAAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAJjOQUAAAACZDMFAAAABHVuaXQFAAAAA25pbAAAAAAceWLv", "height": 1602891, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HiaxjgkBon59CX7NBhKuMdu6wXGxGEenUYX8JGcE3bsA Next: DUtNdMZBKjqiTS6iAApr4kybKuN1keyE54DhFPH81qgE 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 
43.08 ms