tx · vWcCUP2hmEfqY76RapkjBHy55S5VTDW3F2UzJYY9q2P

3NA37aEhY3CSPtrXjKUsNibx5i45P7FxuA4:  -0.01000010 Waves

2021.07.07 13:26 [1603065] smart account 3NA37aEhY3CSPtrXjKUsNibx5i45P7FxuA4 > SELF 0.00000000 Waves

{ "type": 13, "id": "vWcCUP2hmEfqY76RapkjBHy55S5VTDW3F2UzJYY9q2P", "fee": 1000010, "feeAssetId": null, "timestamp": 1625653574453, "version": 2, "chainId": 84, "sender": "3NA37aEhY3CSPtrXjKUsNibx5i45P7FxuA4", "senderPublicKey": "B3Kkg7AgjdZYrAW5kNXeBi1KfWcjdiHpEnu3tsfirQPy", "proofs": [ "Kw1Qq6NKJr9toNRDLLhfUT8yd2BgQMJUVjsxbAGUE9fExdRtW6hEcKmoJ8Y2FgPpQ5CNKCmYQtHzbANq65ojdft" ], "script": "base64:AAIFAAAAAAAAAcQIAhIDCgEIGgoKAmExEgROT05FGhQKAmEyEg5nZXROdW1iZXJCeUtleRoJCgJhMxIDa2V5GgkKAmE0EgNudW0aDQoCYTUSByRtYXRjaDAaBwoCYTYSAWEaEQoCYTcSC2dldFN0ckJ5S2V5GgkKAmE4EgNzdHIaFQoCYTkSD2dldEtleUl0ZW1QcmljZRoKCgJiMRIEaXRlbRoXCgJiMhIRZ2V0VmFsdWVJdGVtUHJpY2UaGwoCYjMSFWdldEtleVVzZXJJdGVtQ291bnRlchoKCgJiNBIEdXNlchodCgJiNRIXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIaGAoCYjYSEmdldEtleUl0ZW1TdXBwbGllchoaCgJiNxIUZ2V0VmFsdWVJdGVtU3VwcGxpZXIaGwoCYjgSFWdldEtleUJhbGFuY2VTdXBwbGllchoNCgJiORIHYWNjb3VudBodCgJjMRIXZ2V0VmFsdWVCYWxhbmNlU3VwcGxpZXIaBwoCYzISAWkaCQoCYzMSA3BtdBoRCgJjNBILdXNlckFkZHJlc3MaCwoCYzUSBXByaWNlGhQKAmM2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gAAAB5XQVZFUyB0b2tlbiBvbmx5IGF0IHRoZSBtb21lbnQEAAAAAmM0CQACWAAAAAEICAUAAAACYzIAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAAJjNQkBAAAAAmIyAAAAAQUAAAACYjEEAAAAAmM2CQEAAAACYjcAAAABBQAAAAJiMQMJAABmAAAAAgUAAAACYzUIBQAAAAJjMwAAAAZhbW91bnQJAAACAAAAAQIAAAAtcHVyY2hhc2UgYW11bnQgY2Fubm90IGJlIGxlc3MgdGhhbiBpdGVtIHByaWNlAwkAAGYAAAACCAUAAAACYzMAAAAGYW1vdW50BQAAAAJjNQkAAAIAAAABAgAAADBwdXJjaGFzZSBhbW91bnQgY2Fubm90IGJlIGhpZ2hlciB0aGFuIGl0ZW0gcHJpY2UDCQAAAAAAAAIFAAAAAmM2BQAAAAJhMQkAAAIAAAABAgAAAB5TdXBwbGllciBhZGRyZXNzIGRvZXNuJ3QgZXhpc3QJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAJiMwAAAAIFAAAAAmM0BQAAAAJiMQkAAGQAAAACCQEAAAACYjUAAAACBQAAAAJjNAUAAAACYjEAAAAAAAAAAAEJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAJiOAAAAAEFAAAAAmM2CQAAZAAAAAIJAQAAAAJjMQAAAAEFAAAAAmM2CAUAAAACYzMAAAAGYW1vdW50BQAAAANuaWwAAAAAT0GD2g==", "height": 1603065, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AzAEvBHtfnCsQHcnd61HGPZGaeGjaWBibsxjtDwak3xb Next: Hzv75npaNZc1rN2vQWxrsm7A3HG7SY6vmMCXnZiWxJxD 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 getKeyItemSupplier (item) = (item + "_data")
4141
4242
4343 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
4444
4545
4646 func getKeyBalanceSupplier (account) = (account + "_balance")
4747
4848
4949 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5050
5151
5252 @Callable(i)
5353 func purchase (item) = {
5454 let pmt = i.payments[0]
5555 if (isDefined(pmt.assetId))
5656 then throw("WAVES token only at the moment")
5757 else {
5858 let userAddress = toBase58String(i.caller.bytes)
5959 let price = getValueItemPrice(item)
6060 let supplierAddres = getValueItemSupplier(item)
6161 if ((price > pmt.amount))
6262 then throw("purchase amunt cannot be less than item price")
6363 else if ((pmt.amount > price))
6464 then throw("purchase amount cannot be higher than item price")
6565 else if ((supplierAddres == NONE))
6666 then throw("Supplier address doesn't exist")
6767 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddres), (getValueBalanceSupplier(supplierAddres) + pmt.amount))]
6868 }
6969 }
7070
7171

github/deemru/w8io/026f985 
39.13 ms