tx · 5pay2oR4YMAQGrAXBqFoZovNh37hmBeK7cLp4mNpyV8L

3N7mmvRnz5E1kLZiYkDYYce7qWuLQMYFzXT:  -0.01400000 Waves

2019.12.13 22:26 [807508] smart account 3N7mmvRnz5E1kLZiYkDYYce7qWuLQMYFzXT > SELF 0.00000000 Waves

{ "type": 13, "id": "5pay2oR4YMAQGrAXBqFoZovNh37hmBeK7cLp4mNpyV8L", "fee": 1400000, "feeAssetId": null, "timestamp": 1576265196365, "version": 1, "sender": "3N7mmvRnz5E1kLZiYkDYYce7qWuLQMYFzXT", "senderPublicKey": "571z2nNJThBFYDwuwuveXdTYBjYVtwDd5wSA45DqH1bw", "proofs": [ "66uA5qtqTGPorxkFuYLSPAnBsepQbAuHDeniaUjhT5o8yCmbWyaraNxm3csaJBUnXEV2rjrCmwmmrFcSakSEPf1E" ], "script": "base64:AAIDAAAAAAAAAA4IARIFCgMIAQgSAwoBCAAAAA0AAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABAAAABGl0ZW0JAQAAAA5nZXROdW1iZXJCeUtleQAAAAEJAQAAAA9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GllckFkZHJlc3MJAQAAABRnZXRWYWx1ZUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0DCQAAZgAAAAIFAAAABXByaWNlCAUAAAADcG10AAAABmFtb3VudAkAAAIAAAABAgAAAAVlcnJvcgMJAABmAAAAAggFAAAAA3BtdAAAAAZhbW91bnQFAAAABXByaWNlCQAAAgAAAAECAAAABWVycm9yAwkAAAAAAAACBQAAAA9zdXBwbGllckFkZHJlc3MFAAAABE5PTkUJAAACAAAAAQIAAAAFZXJyb3IJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABVnZXRLZXlVc2VySXRlbUNvdW50ZXIAAAACBQAAAAt1c2VyQWRkcmVzcwUAAAAEaXRlbQkAAGQAAAACCQEAAAAXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIAAAACBQAAAAt1c2VyQWRkcmVzcwUAAAAEaXRlbQAAAAAAAAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFWdldEtleUJhbGFuY2VTdXBwbGllcgAAAAEFAAAAD3N1cHBsaWVyQWRkcmVzcwkAAGQAAAACCQEAAAAXZ2V0VmFsdWVCYWxhbmNlU3VwcGxpZXIAAAABBQAAAA9zdXBwbGllckFkZHJlc3MIBQAAAANwbXQAAAAGYW1vdW50BQAAAANuaWwAAAAAPg3eqw==", "chainId": 84, "height": 807508, "spentComplexity": 0 } View: original | compacted Prev: 7nVctESHt4FASWFy4A6tBLmMGCsijzobGFdydnLYaLiP Next: xRkXADQGS5uhfu4qFWaSYkuV232HDN4wqiPqo12odB6 Diff:
OldNewDifferences
6767 }
6868
6969
70+
71+@Callable(i)
72+func purchase (item) = {
73+ let pmt = extract(i.payment)
74+ if (isDefined(pmt.assetId))
75+ then throw("Only WAVES token at that moment")
76+ else {
77+ let userAddress = toBase58String(i.caller.bytes)
78+ let price = getValueItemPrice(item)
79+ let supplierAddress = getValueItemSupplier(item)
80+ if ((price > pmt.amount))
81+ then throw("error")
82+ else if ((pmt.amount > price))
83+ then throw("error")
84+ else if ((supplierAddress == NONE))
85+ then throw("error")
86+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
87+ }
88+ }
89+
90+
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("asdad")
6666 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
6767 }
6868
6969
70+
71+@Callable(i)
72+func purchase (item) = {
73+ let pmt = extract(i.payment)
74+ if (isDefined(pmt.assetId))
75+ then throw("Only WAVES token at that moment")
76+ else {
77+ let userAddress = toBase58String(i.caller.bytes)
78+ let price = getValueItemPrice(item)
79+ let supplierAddress = getValueItemSupplier(item)
80+ if ((price > pmt.amount))
81+ then throw("error")
82+ else if ((pmt.amount > price))
83+ then throw("error")
84+ else if ((supplierAddress == NONE))
85+ then throw("error")
86+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
87+ }
88+ }
89+
90+

github/deemru/w8io/026f985 
36.04 ms