tx · 7weBWfw48N6XMNqLVfqE7ZhqPx1RBP4uq9gohrgceXnT

3MpEvJUwR46tdPKYd9mfoSeigDVDJzNDp8y:  -0.01000000 Waves

2021.07.06 17:54 [1601899] smart account 3MpEvJUwR46tdPKYd9mfoSeigDVDJzNDp8y > SELF 0.00000000 Waves

{ "type": 13, "id": "7weBWfw48N6XMNqLVfqE7ZhqPx1RBP4uq9gohrgceXnT", "fee": 1000000, "feeAssetId": null, "timestamp": 1625583291979, "version": 2, "chainId": 84, "sender": "3MpEvJUwR46tdPKYd9mfoSeigDVDJzNDp8y", "senderPublicKey": "AjfGmMcujRDveyKiyrN2DkvnXKsxRmq4XFA9kZjb3iZh", "proofs": [ "3bh6BYVZg924XVdgA3rWu4qrYW2LUgxHY63Ji6wcxkQXB1sNt5Sv7nupASEqu6Wz1mXLtUB7HzBiAFttQFDhWiHS" ], "script": "base64:AAIFAAAAAAAAAh0IAhIFCgMIAQgSAwoBCBoKCgJhMRIETk9ORRoUCgJhMhIOZ2V0TnVtYmVyQnlLZXkaCQoCYTMSA2tleRoJCgJhNBIDbnVtGg0KAmE1EgckbWF0Y2gwGgcKAmE2EgFhGhEKAmE3EgtnZXRTdHJCeUtleRoJCgJhOBIDc3RyGhUKAmE5Eg9nZXRLZXlJdGVtUHJpY2UaCgoCYjESBGl0ZW0aFwoCYjISEWdldFZhbHVlSXRlbVByaWNlGhsKAmIzEhVnZXRLZXlVc2VySXRlbUNvdW50ZXIaCgoCYjQSBHVzZXIaHQoCYjUSF2dldFZhbHVlVXNlckl0ZW1Db3VudGVyGhAKAmI2EgpnZXRLZXlJdGVtGg4KAmI3EghzdXBwbGllchoLCgJiOBIFdGl0bGUaFAoCYjkSDmdldEtleUl0ZW1EYXRhGhgKAmMxEhJnZXRLZXlJdGVtU3VwcGxpZXIaGgoCYzISFGdldFZhbHVlSXRlbVN1cHBsaWVyGhsKAmMzEhVnZXRLZXlCYWxhbmNlU3VwcGxpZXIaDQoCYzQSB2FjY291bnQaHQoC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AAACBQAAAAJjNwgFAAAAAmQxAAAABmFtb3VudAkAAAIAAAABAgAAAC5QdXJjaGFzZSBhbW91bnQgY2Fubm90IGJlIGxlc3MgdGhhbiBpdGVtIHByaWNlAwkAAAAAAAACBQAAAAJjOQUAAAACYTEJAAACAAAAAQIAAAAXU3VwcGxpZXIgZG9lcyBub3QgZXhpc3QJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAJiMwAAAAIFAAAAAmQyBQAAAAJiMQkAAGQAAAACCQEAAAACYjUAAAACBQAAAAJkMgUAAAACYjEAAAAAAAAAAAEJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAJjMwAAAAEFAAAAAmM5CQAAZAAAAAIJAQAAAAJjNQAAAAEFAAAAAmM5CAUAAAACZDEAAAAGYW1vdW50BQAAAANuaWwAAAAARhiIrg==", "height": 1601899, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9isErRybcPpjiu8K7bh5H3Zp77y6aiU41zo16b7m2XF5 Next: Ha2tgRsLspMCkWY8pzCVhgWCdA88oWsuwewTRrEn1eCw 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

github/deemru/w8io/026f985 
36.64 ms