tx · BaCnbzkWrq5fZxWFTKA5ZQo27tYLKfP92Ti7RQqfzG4q

3MvVZ5AroXL8DZKAmuENPSLDrgcfcvzdVSj:  -0.01400000 Waves

2019.12.09 15:42 [801254] smart account 3MvVZ5AroXL8DZKAmuENPSLDrgcfcvzdVSj > SELF 0.00000000 Waves

{ "type": 13, "id": "BaCnbzkWrq5fZxWFTKA5ZQo27tYLKfP92Ti7RQqfzG4q", "fee": 1400000, "feeAssetId": null, "timestamp": 1575895322204, "version": 1, "sender": "3MvVZ5AroXL8DZKAmuENPSLDrgcfcvzdVSj", "senderPublicKey": "2UynDMb6k4udKULdb2QVAXTd6ppGoe8VnAeSjJqNYfRz", "proofs": [ "2456CAJudpXRtjjK5MNyqy49VPuZR5seSeV79C962eLSA8on9mGMKR7wwpstE7vZuoDEETzgSs9fW53pLYyDHs7k" ], "script": "base64:AAIDAAAAAAAAABAIARIFCgMIAQgSAwoBCBIAAAAADQAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAABFnZXRWYWx1ZUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkBAAAADmdldE51bWJlckJ5S2V5AAAAAQ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mFsYW5jZVN1cHBsaWVyAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzAwkAAGcAAAACAAAAAAAAAAAABQAAAAdiYWxhbmNlCQAAAgAAAAECAAAAFGluc3VmZmljaWVudCBiYWxhbmNlCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFWdldEtleUJhbGFuY2VTdXBwbGllcgAAAAEFAAAAD3N1cHBsaWVyQWRkcmVzcwAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzBQAAAAdiYWxhbmNlBQAAAAR1bml0BQAAAANuaWwAAAAA6nOiyw==", "chainId": 84, "height": 801254, "spentComplexity": 0 } View: original | compacted Prev: 4BuD23wT1PCZ9SadC6BpUAYeVA84G4nUuwTdhkhCm5nE Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
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 is already exist")
6666 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), 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("WAVES tokens only at the moment")
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 ((pmt.amount > price))
8383 then throw("purchase amount cannot be higher than item price")
8484 else if ((supplierAddress == NONE))
8585 then throw("supplier does not exist")
8686 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
8787 }
8888 }
8989
9090
9191
9292 @Callable(i)
9393 func withdraw () = {
9494 let supplierAddress = toBase58String(i.caller.bytes)
9595 let balance = getValueBalanceSupplier(supplierAddress)
9696 if ((0 >= balance))
9797 then throw("insufficient balance")
9898 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
9999 }
100100
101101

github/deemru/w8io/026f985 
35.58 ms