tx · GY1d3fNpDDQpDPH6wfFoGwHj9uvXXbbXKQUxkzZi5sGX

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.08.28 00:13 [650129] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "GY1d3fNpDDQpDPH6wfFoGwHj9uvXXbbXKQUxkzZi5sGX", "fee": 1400000, "feeAssetId": null, "timestamp": 1566940472872, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "2etvVF72EdnaWN1BSDabcjMAg3yXg9n1r7SGUQGAPoWLbmAMaMr1ZoYnhaC9pMsp1azcqV2cgDYSwJzjTXMJCt1P" ], "script": "base64:AAIDAAAAAAAAAAAAAAAQAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAAClRva2VuUHJpY2UAAAAAAAAAAAoAAAAAEERPTkFURUNPVU5URVJLRVkCAAAACyRET05BVEVfTlVNAAAAAAdCVVlJVEVNAgAAAAkkQlVZX0lURU0AAAAABEJhZzEJAABoAAAAAgAAAAAAAAAAAQUAAAAHV0FWRUxFVAAAAAAEQmFnNQkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAVCYWcxMAkAAGgAAAACAAAAAAAAAAAKBQAAAAdXQVZFTEVUAAAAAAVCYWcyMAkAAGgAAAACAAAAAAAAAAAUBQAAAAdXQVZFTEVUAAAAAAVCYWc1MAkAAGgAAAACAAAAAAAAAAAyBQAAAAdXQVZFTEVUAAAAAAZCYWcxMDAJAABoAAAAAgAAAAAAAA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TZXQAAAABBQAAAApkb25hdGVEYXRhCQAAAgAAAAECAAAAGVlvdSBwYWlkIHRoZSB3cm9uZyBhbW91bnQAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAAAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAN0dHgFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAADc3R4BQAAAAckbWF0Y2gwBgcHkSncpw==", "chainId": 84, "height": 650129, "spentComplexity": 0 } View: original | compacted Prev: 32kGkj89KUW4ci8NGuHUXTBrGhMScP865vLDZBkySyhT Next: GN8tJPmxbWbXtCRvcWaE56yjth8Czs26jZPd9K6X5FHb Diff:
OldNewDifferences
2323
2424 let Bag100 = (100 * WAVELET)
2525
26+let itemMax = 20
27+
28+let prices = [1, 3, 5, 6, 2, 2, 4, 9, 10, 12, 5, 1, 9, 12, 5, 4, 1, 11, 12, 9]
29+
2630 func IncrementDonateNum () = {
2731 let gameNum = match getInteger(this, DONATECOUNTERKEY) {
2832 case num: Int =>
4549 }
4650
4751
48-func ExtractItemsList (key) = {
49- let rawDataStr = match getString(this, key) {
50- case str: String =>
51- str
52- case _ =>
53- ""
54- }
55- rawDataStr
56- }
57-
58-
59-func getPriceByItemID (itemId) = if ((itemId == "1"))
60- then 1
61- else if ((itemId == "2"))
62- then 4
63- else if ((itemId == "3"))
64- then 6
65- else throw("Неверный ID item")
66-
67-
6852 func isItemExist (oldItemsList,itemId) = {
6953 let rawDataStr = match indexOf(oldItemsList, (itemId + ":")) {
7054 case int: Int =>
7761
7862
7963 @Callable(i)
80-func buy (itemId) = {
64+func buyItem (itemId) = {
8165 let buyTXId = toBase58String(i.transactionId)
8266 let playerAddress = toString(i.caller)
83- let key2Items = (playerAddress + "_items")
84- let balanceMinus = getPriceByItemID(itemId)
85- let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus)
86- let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance)
87- let oldItemsList = ExtractItemsList(key2Items)
88- let searchResult = isItemExist(oldItemsList, itemId)
89- if ((searchResult == "undefined"))
90- then throw("This item not exist")
91- else throw((("Новый список айтемов: " + itemId) + ":2"))
67+ if (if ((itemId > 0))
68+ then (itemMax >= itemId)
69+ else false)
70+ then {
71+ let balanceMinus = prices[itemId]
72+ let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus)
73+ let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance)
74+ let keyToItem = ((playerAddress + "_itemID_") + toString(itemId))
75+ WriteSet([DataEntry(keyToItem, 1), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData])
76+ }
77+ else throw("Item has not found")
9278 }
9379
9480
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
26+let itemMax = 20
27+
28+let prices = [1, 3, 5, 6, 2, 2, 4, 9, 10, 12, 5, 1, 9, 12, 5, 4, 1, 11, 12, 9]
29+
2630 func IncrementDonateNum () = {
2731 let gameNum = match getInteger(this, DONATECOUNTERKEY) {
2832 case num: Int =>
2933 num
3034 case _ =>
3135 0
3236 }
3337 (gameNum + 1)
3438 }
3539
3640
3741 func getBalance (key) = {
3842 let playerBalanceNum = match getInteger(this, key) {
3943 case playerBalanceNum: Int =>
4044 playerBalanceNum
4145 case _ =>
4246 0
4347 }
4448 playerBalanceNum
4549 }
4650
4751
48-func ExtractItemsList (key) = {
49- let rawDataStr = match getString(this, key) {
50- case str: String =>
51- str
52- case _ =>
53- ""
54- }
55- rawDataStr
56- }
57-
58-
59-func getPriceByItemID (itemId) = if ((itemId == "1"))
60- then 1
61- else if ((itemId == "2"))
62- then 4
63- else if ((itemId == "3"))
64- then 6
65- else throw("Неверный ID item")
66-
67-
6852 func isItemExist (oldItemsList,itemId) = {
6953 let rawDataStr = match indexOf(oldItemsList, (itemId + ":")) {
7054 case int: Int =>
7155 toString(int)
7256 case _ =>
7357 "undefined"
7458 }
7559 rawDataStr
7660 }
7761
7862
7963 @Callable(i)
80-func buy (itemId) = {
64+func buyItem (itemId) = {
8165 let buyTXId = toBase58String(i.transactionId)
8266 let playerAddress = toString(i.caller)
83- let key2Items = (playerAddress + "_items")
84- let balanceMinus = getPriceByItemID(itemId)
85- let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus)
86- let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance)
87- let oldItemsList = ExtractItemsList(key2Items)
88- let searchResult = isItemExist(oldItemsList, itemId)
89- if ((searchResult == "undefined"))
90- then throw("This item not exist")
91- else throw((("Новый список айтемов: " + itemId) + ":2"))
67+ if (if ((itemId > 0))
68+ then (itemMax >= itemId)
69+ else false)
70+ then {
71+ let balanceMinus = prices[itemId]
72+ let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus)
73+ let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance)
74+ let keyToItem = ((playerAddress + "_itemID_") + toString(itemId))
75+ WriteSet([DataEntry(keyToItem, 1), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData])
76+ }
77+ else throw("Item has not found")
9278 }
9379
9480
9581
9682 @Callable(i)
9783 func reset () = {
9884 let playerAddress = toString(i.caller)
9985 let donateData = [DataEntry(DONATECOUNTERKEY, 0), DataEntry((playerAddress + "_balance"), 0)]
10086 WriteSet(donateData)
10187 }
10288
10389
10490
10591 @Callable(i)
10692 func donate () = {
10793 let newGameNum = IncrementDonateNum()
10894 let donateId = toBase58String(i.transactionId)
10995 let pmt = extract(i.payment)
11096 let playerAddress = toString(i.caller)
11197 let betNotInWaves = isDefined(pmt.assetId)
11298 let feeNotInWaves = isDefined(pmt.assetId)
11399 let donateAmt = pmt.amount
114100 if (betNotInWaves)
115101 then throw("Bet amount must be in Waves")
116102 else if (feeNotInWaves)
117103 then throw("Transaction's fee must be in Waves")
118104 else {
119105 let donateAmtValid = if (if (if (if (if (if ((donateAmt == (Bag1 + COMMISSION)))
120106 then true
121107 else (donateAmt == (Bag5 + COMMISSION)))
122108 then true
123109 else (donateAmt == (Bag10 + COMMISSION)))
124110 then true
125111 else (donateAmt == (Bag20 + COMMISSION)))
126112 then true
127113 else (donateAmt == (Bag50 + COMMISSION)))
128114 then true
129115 else (donateAmt == (Bag100 + COMMISSION)))
130116 then true
131117 else false
132118 if (donateAmtValid)
133119 then {
134120 let donateNum = ((donateAmt - COMMISSION) / WAVELET)
135121 let key2Balance = (playerAddress + "_balance")
136122 let newBalance = (getBalance(key2Balance) + (donateNum * TokenPrice))
137123 let donateData = [DataEntry(DONATECOUNTERKEY, newGameNum), DataEntry(key2Balance, newBalance), DataEntry(donateId, donateNum)]
138124 WriteSet(donateData)
139125 }
140126 else throw("You paid the wrong amount")
141127 }
142128 }
143129
144130
145131 @Verifier(tx)
146132 func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
147133 then match tx {
148134 case ttx: TransferTransaction =>
149135 true
150136 case stx: SetScriptTransaction =>
151137 true
152138 case _ =>
153139 false
154140 }
155141 else false
156142

github/deemru/w8io/026f985 
27.12 ms