tx · 2zBg3v3Fk7F4DWxJNcgHSg8D4bXy1kzC8kQERgSLQ845

3MyXnDWMtqpfkuFJtyBHaUWoWxtGoD8SpBQ:  -0.01400000 Waves

2020.11.20 16:28 [1273762] smart account 3MyXnDWMtqpfkuFJtyBHaUWoWxtGoD8SpBQ > SELF 0.00000000 Waves

{ "type": 13, "id": "2zBg3v3Fk7F4DWxJNcgHSg8D4bXy1kzC8kQERgSLQ845", "fee": 1400000, "feeAssetId": null, "timestamp": 1605878977169, "version": 2, "chainId": 84, "sender": "3MyXnDWMtqpfkuFJtyBHaUWoWxtGoD8SpBQ", "senderPublicKey": "FYobWqooJHEVQFRHr8NU7ewYZ2AJdMzuDBm8WR9PiAx1", "proofs": [ "4uDwW2dvr9Tq4mmmM9ukg9fqCM3Gwx5VL7rtA1Dcywf8bRbbZa5vCEhvttLT52wtcq84VqvVvStSP7jRthxsnnrS" ], "script": "base64:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAABAAAAAAEWFjY291bnQxUHVibGljS2V5AQAAACD3jXgw7OE1lYUdW8zpPeJRbBzq2i/QfxUY9F31TI9ITgAAAAARYWNjb3VudDJQdWJsaWNLZXkBAAAAIBtXv2hMCq7TJHKvVsoiywB7SjyYC3f6AKFF3CrlAyIVAAAAAA5vdGhlclB1YmxpY0tleQEAAAAg525Riaa48RgJvYxM/FeTNEzhBum4Tb2zEKrgTa8dHVoAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEA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QAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABpWJm/U=", "height": 1273762, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8vAkNbbMXYUqyznSwWuYzNCk2gLxB7SLSsehR8pgnPxF Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd'
55
66 let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv'
77
88 let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw'
99
1010 let NONE = "none"
1111
1212 func getNumberByKey (key) = {
1313 let num = match getInteger(this, key) {
1414 case a: Int =>
1515 a
1616 case _ =>
1717 0
1818 }
1919 num
2020 }
2121
2222
2323 func getStrByKey (key) = {
2424 let str = match getString(this, key) {
2525 case a: String =>
2626 a
2727 case _ =>
2828 NONE
2929 }
3030 str
3131 }
3232
3333
3434 func getKeyItemPrice (item) = (item + "_price")
3535
3636
3737 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3838
3939
4040 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4141
4242
4343 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4444
4545
4646 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4747
4848
4949 func getKeyItemData (item) = (item + "_data")
5050
5151
5252 func getKeyItemSupplier (item) = (item + "_owner")
5353
5454
5555 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5656
5757
5858 func getKeyBalanceSupplier (account) = (account + "_balance")
5959
6060
6161 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6262
6363
6464 @Callable(i)
6565 func purchase (coupon) = {
6666 let pmt = value(i.payments)
6767 if (isDefined(pmt[0].assetId))
6868 then throw("only wws")
6969 else {
7070 let customerAddress = toBase58String(i.caller.bytes)
7171 let price = match getInteger(this, (coupon + "_coupon_price")) {
7272 case a: Int =>
7373 a
7474 case _ =>
7575 0
7676 }
7777 if ((price == 0))
7878 then throw("coupon not found")
7979 else if ((price > pmt[0].amount))
8080 then throw("moar moeny")
8181 else if ((pmt[0].amount > price))
8282 then throw(toString(price))
8383 else if ((size(pmt) > 1))
8484 then throw("single item only")
8585 else [StringEntry(((("status:purchase_" + coupon) + "_customer_") + customerAddress), "confirmed"), IntegerEntry(((("price:purchase_" + coupon) + "_customer_") + customerAddress), price)]
8686 }
8787 }
8888
8989
9090
9191 @Callable(i)
9292 func addItem (title,price,data) = {
9393 let supplierAddress = toBase58String(i.caller.bytes)
9494 let item = getKeyItem(supplierAddress, title)
9595 if ((0 >= price))
9696 then throw("purchase amount cannot be less than item price")
9797 else if ((getValueItemSupplier(item) != NONE))
9898 then throw("an item already exist")
9999 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
100100 }
101101
102102
103103 @Verifier(tx)
104104 func verify () = true
105105

github/deemru/w8io/169f3d6 
30.00 ms