tx · 81e8LDeP4zHvSMfPz2y4Ara8wbSrBcCDyxJXjKmyZf5h

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.08.28 00:33 [650150] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "81e8LDeP4zHvSMfPz2y4Ara8wbSrBcCDyxJXjKmyZf5h", "fee": 1400000, "feeAssetId": null, "timestamp": 1566941616994, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "3zmgDeaPW1NeVpiJkQwpMc3R9z7WTACn9e9jy5UdCriV4MhNQ21MX9G7BEeB2RnCainopq54BCga6H9qETDW1djV" ], "script": "base64:AAIDAAAAAAAAAAAAAAARAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAAClRva2VuUHJpY2UAAAAAAAAAAAoAAAAAEERPTkFURUNPVU5URVJLRVkCAAAACyRET05BVEVfTlVNAAAAAAdCVVlJVEVNAgAAAAkkQlVZX0lURU0AAAAABEJhZzEJAABoAAAAAgAAAAAAAAAAAQUAAAAHV0FWRUxFVAAAAAAEQmFnNQkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAVCYWcxMAkAAGgAAAACAAAAAAAAAAAKBQAAAAdXQVZFTEVUAAAAAAVCYWcyMAkAAGgAAAACAAAAAAAAAAAUBQAAAAdXQVZFTEVUAAAAAAVCYWc1MAkAAGgAAAACAAAAAAAAAAAyBQAAAAdXQVZFTEVUAAAAAAZCYWcxMDAJAABoAAAAAgAAAAAAAAAAZAUAAA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GFuY2UAAAABBQAAAAtrZXkyQmFsYW5jZQkAAGgAAAACBQAAAAlkb25hdGVOdW0FAAAAClRva2VuUHJpY2UEAAAACmRvbmF0ZURhdGEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAEERPTkFURUNPVU5URVJLRVkFAAAACm5ld0dhbWVOdW0JAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAC2tleTJCYWxhbmNlBQAAAApuZXdCYWxhbmNlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAhkb25hdGVJZAUAAAAJZG9uYXRlTnVtBQAAAANuaWwJAQAAAAhXcml0ZVNldAAAAAEFAAAACmRvbmF0ZURhdGEJAAACAAAAAQIAAAAZWW91IHBhaWQgdGhlIHdyb25nIGFtb3VudAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAADCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAA3R0eAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAANzdHgFAAAAByRtYXRjaDAGBwcxd4yr", "chainId": 84, "height": 650150, "spentComplexity": 0 } View: original | compacted Prev: DW9N6GzVT9dS6xnAENzXWCwFyU4p7TFkjpnRNNAvzQeQ Next: CFW7wT9GkPHJ6X8nhsJgpveGuRPdRZSz6Cv9B2Ss7qFe Diff:
OldNewDifferences
6060 }
6161
6262
63+func getUserItemByKey (key) = {
64+ let rawDataStr = match getInteger(this, key) {
65+ case int: Int =>
66+ int
67+ case _ =>
68+ 0
69+ }
70+ rawDataStr
71+ }
72+
73+
6374 @Callable(i)
6475 func buyItem (itemId) = {
6576 let buyTXId = toBase58String(i.transactionId)
7283 let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus)
7384 let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance)
7485 let keyToItem = ((playerAddress + "_itemID_") + toString(itemId))
75- WriteSet([DataEntry(keyToItem, 1), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData])
86+ let currentItemAmount = getUserItemByKey(keyToItem)
87+ WriteSet([DataEntry(keyToItem, (currentItemAmount + 1)), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData])
7688 }
7789 else throw("Item has not found")
7890 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let WAVELET = ((100 * 1000) * 1000)
55
66 let COMMISSION = ((5 * WAVELET) / 1000)
77
88 let TokenPrice = 10
99
1010 let DONATECOUNTERKEY = "$DONATE_NUM"
1111
1212 let BUYITEM = "$BUY_ITEM"
1313
1414 let Bag1 = (1 * WAVELET)
1515
1616 let Bag5 = (5 * WAVELET)
1717
1818 let Bag10 = (10 * WAVELET)
1919
2020 let Bag20 = (20 * WAVELET)
2121
2222 let Bag50 = (50 * WAVELET)
2323
2424 let Bag100 = (100 * WAVELET)
2525
2626 let itemMax = 20
2727
2828 let prices = [1, 3, 5, 6, 2, 2, 4, 9, 10, 12, 5, 1, 9, 12, 5, 4, 1, 11, 12, 9]
2929
3030 func IncrementDonateNum () = {
3131 let gameNum = match getInteger(this, DONATECOUNTERKEY) {
3232 case num: Int =>
3333 num
3434 case _ =>
3535 0
3636 }
3737 (gameNum + 1)
3838 }
3939
4040
4141 func getBalance (key) = {
4242 let playerBalanceNum = match getInteger(this, key) {
4343 case playerBalanceNum: Int =>
4444 playerBalanceNum
4545 case _ =>
4646 0
4747 }
4848 playerBalanceNum
4949 }
5050
5151
5252 func isItemExist (oldItemsList,itemId) = {
5353 let rawDataStr = match indexOf(oldItemsList, (itemId + ":")) {
5454 case int: Int =>
5555 toString(int)
5656 case _ =>
5757 "undefined"
5858 }
5959 rawDataStr
6060 }
6161
6262
63+func getUserItemByKey (key) = {
64+ let rawDataStr = match getInteger(this, key) {
65+ case int: Int =>
66+ int
67+ case _ =>
68+ 0
69+ }
70+ rawDataStr
71+ }
72+
73+
6374 @Callable(i)
6475 func buyItem (itemId) = {
6576 let buyTXId = toBase58String(i.transactionId)
6677 let playerAddress = toString(i.caller)
6778 if (if ((itemId > 0))
6879 then (itemMax >= itemId)
6980 else false)
7081 then {
7182 let balanceMinus = prices[itemId]
7283 let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus)
7384 let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance)
7485 let keyToItem = ((playerAddress + "_itemID_") + toString(itemId))
75- WriteSet([DataEntry(keyToItem, 1), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData])
86+ let currentItemAmount = getUserItemByKey(keyToItem)
87+ WriteSet([DataEntry(keyToItem, (currentItemAmount + 1)), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData])
7688 }
7789 else throw("Item has not found")
7890 }
7991
8092
8193
8294 @Callable(i)
8395 func reset () = {
8496 let playerAddress = toString(i.caller)
8597 let donateData = [DataEntry(DONATECOUNTERKEY, 0), DataEntry((playerAddress + "_balance"), 0)]
8698 WriteSet(donateData)
8799 }
88100
89101
90102
91103 @Callable(i)
92104 func donate () = {
93105 let newGameNum = IncrementDonateNum()
94106 let donateId = toBase58String(i.transactionId)
95107 let pmt = extract(i.payment)
96108 let playerAddress = toString(i.caller)
97109 let betNotInWaves = isDefined(pmt.assetId)
98110 let feeNotInWaves = isDefined(pmt.assetId)
99111 let donateAmt = pmt.amount
100112 if (betNotInWaves)
101113 then throw("Bet amount must be in Waves")
102114 else if (feeNotInWaves)
103115 then throw("Transaction's fee must be in Waves")
104116 else {
105117 let donateAmtValid = if (if (if (if (if (if ((donateAmt == (Bag1 + COMMISSION)))
106118 then true
107119 else (donateAmt == (Bag5 + COMMISSION)))
108120 then true
109121 else (donateAmt == (Bag10 + COMMISSION)))
110122 then true
111123 else (donateAmt == (Bag20 + COMMISSION)))
112124 then true
113125 else (donateAmt == (Bag50 + COMMISSION)))
114126 then true
115127 else (donateAmt == (Bag100 + COMMISSION)))
116128 then true
117129 else false
118130 if (donateAmtValid)
119131 then {
120132 let donateNum = ((donateAmt - COMMISSION) / WAVELET)
121133 let key2Balance = (playerAddress + "_balance")
122134 let newBalance = (getBalance(key2Balance) + (donateNum * TokenPrice))
123135 let donateData = [DataEntry(DONATECOUNTERKEY, newGameNum), DataEntry(key2Balance, newBalance), DataEntry(donateId, donateNum)]
124136 WriteSet(donateData)
125137 }
126138 else throw("You paid the wrong amount")
127139 }
128140 }
129141
130142
131143 @Verifier(tx)
132144 func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
133145 then match tx {
134146 case ttx: TransferTransaction =>
135147 true
136148 case stx: SetScriptTransaction =>
137149 true
138150 case _ =>
139151 false
140152 }
141153 else false
142154

github/deemru/w8io/026f985 
34.05 ms