tx · GN8tJPmxbWbXtCRvcWaE56yjth8Czs26jZPd9K6X5FHb 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs: -0.01400000 Waves 2019.08.28 00:17 [650131] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves
{ "type": 13, "id": "GN8tJPmxbWbXtCRvcWaE56yjth8Czs26jZPd9K6X5FHb", "fee": 1400000, "feeAssetId": null, "timestamp": 1566940664700, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "iCeCzwcNfAmKQmF4QW5a7TXyRECwuQpNT9u6kM7dJHnbuv5q5Y6Gx2HFsjmyPnn4Fb83yjrF7dptsS6ff9RDToM" ], "script": "base64:AAIDAAAAAAAAAAAAAAAQAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAAClRva2VuUHJpY2UAAAAAAAAAAAoAAAAAEERPTkFURUNPVU5URVJLRVkCAAAACyRET05BVEVfTlVNAAAAAAdCVVlJVEVNAgAAAAkkQlVZX0lURU0AAAAABEJhZzEJAABoAAAAAgAAAAAAAAAAAQUAAAAHV0FWRUxFVAAAAAAEQmFnNQkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAVCYWcxMAkAAGgAAAACAAAAAAAAAAAKBQAAAAdXQVZFTEVUAAAAAAVCYWcyMAkAAGgAAAACAAAAAAAAAAAUBQAAAAdXQVZFTEVUAAAAAAVCYWc1MAkAAGgAAAACAAAAAAAAAAAyBQAAAAdXQVZFTEVUAAAAAAZCYWcxMDAJAABoAAAAAgAAAAAAAAAAZAUA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dSBwYWlkIHRoZSB3cm9uZyBhbW91bnQAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAAAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAN0dHgFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAADc3R4BQAAAAckbWF0Y2gwBgcH1jFnZQ==", "chainId": 84, "height": 650131, "spentComplexity": 0 } View: original | compacted Prev: GY1d3fNpDDQpDPH6wfFoGwHj9uvXXbbXKQUxkzZi5sGX Next: DJU3Nw2ZUdBCc5Dp4iYvpXoKdw3rPazAMt8rSYu7PVY5 Diff:
Old | New | Differences | |
---|---|---|---|
64 | 64 | func buyItem (itemId) = { | |
65 | 65 | let buyTXId = toBase58String(i.transactionId) | |
66 | 66 | let playerAddress = toString(i.caller) | |
67 | - | if (if ((itemId > 0)) | |
68 | - | then (itemMax >= itemId) | |
69 | - | else false) | |
67 | + | if ((itemMax >= itemId)) | |
70 | 68 | then { | |
71 | 69 | let balanceMinus = prices[itemId] | |
72 | 70 | let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let WAVELET = ((100 * 1000) * 1000) | |
5 | 5 | ||
6 | 6 | let COMMISSION = ((5 * WAVELET) / 1000) | |
7 | 7 | ||
8 | 8 | let TokenPrice = 10 | |
9 | 9 | ||
10 | 10 | let DONATECOUNTERKEY = "$DONATE_NUM" | |
11 | 11 | ||
12 | 12 | let BUYITEM = "$BUY_ITEM" | |
13 | 13 | ||
14 | 14 | let Bag1 = (1 * WAVELET) | |
15 | 15 | ||
16 | 16 | let Bag5 = (5 * WAVELET) | |
17 | 17 | ||
18 | 18 | let Bag10 = (10 * WAVELET) | |
19 | 19 | ||
20 | 20 | let Bag20 = (20 * WAVELET) | |
21 | 21 | ||
22 | 22 | let Bag50 = (50 * WAVELET) | |
23 | 23 | ||
24 | 24 | let Bag100 = (100 * WAVELET) | |
25 | 25 | ||
26 | 26 | let itemMax = 20 | |
27 | 27 | ||
28 | 28 | let prices = [1, 3, 5, 6, 2, 2, 4, 9, 10, 12, 5, 1, 9, 12, 5, 4, 1, 11, 12, 9] | |
29 | 29 | ||
30 | 30 | func IncrementDonateNum () = { | |
31 | 31 | let gameNum = match getInteger(this, DONATECOUNTERKEY) { | |
32 | 32 | case num: Int => | |
33 | 33 | num | |
34 | 34 | case _ => | |
35 | 35 | 0 | |
36 | 36 | } | |
37 | 37 | (gameNum + 1) | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getBalance (key) = { | |
42 | 42 | let playerBalanceNum = match getInteger(this, key) { | |
43 | 43 | case playerBalanceNum: Int => | |
44 | 44 | playerBalanceNum | |
45 | 45 | case _ => | |
46 | 46 | 0 | |
47 | 47 | } | |
48 | 48 | playerBalanceNum | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func isItemExist (oldItemsList,itemId) = { | |
53 | 53 | let rawDataStr = match indexOf(oldItemsList, (itemId + ":")) { | |
54 | 54 | case int: Int => | |
55 | 55 | toString(int) | |
56 | 56 | case _ => | |
57 | 57 | "undefined" | |
58 | 58 | } | |
59 | 59 | rawDataStr | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | @Callable(i) | |
64 | 64 | func buyItem (itemId) = { | |
65 | 65 | let buyTXId = toBase58String(i.transactionId) | |
66 | 66 | let playerAddress = toString(i.caller) | |
67 | - | if (if ((itemId > 0)) | |
68 | - | then (itemMax >= itemId) | |
69 | - | else false) | |
67 | + | if ((itemMax >= itemId)) | |
70 | 68 | then { | |
71 | 69 | let balanceMinus = prices[itemId] | |
72 | 70 | let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus) | |
73 | 71 | let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance) | |
74 | 72 | let keyToItem = ((playerAddress + "_itemID_") + toString(itemId)) | |
75 | 73 | WriteSet([DataEntry(keyToItem, 1), DataEntry(((BUYITEM + "_") + buyTXId), itemId), newBalanceData]) | |
76 | 74 | } | |
77 | 75 | else throw("Item has not found") | |
78 | 76 | } | |
79 | 77 | ||
80 | 78 | ||
81 | 79 | ||
82 | 80 | @Callable(i) | |
83 | 81 | func reset () = { | |
84 | 82 | let playerAddress = toString(i.caller) | |
85 | 83 | let donateData = [DataEntry(DONATECOUNTERKEY, 0), DataEntry((playerAddress + "_balance"), 0)] | |
86 | 84 | WriteSet(donateData) | |
87 | 85 | } | |
88 | 86 | ||
89 | 87 | ||
90 | 88 | ||
91 | 89 | @Callable(i) | |
92 | 90 | func donate () = { | |
93 | 91 | let newGameNum = IncrementDonateNum() | |
94 | 92 | let donateId = toBase58String(i.transactionId) | |
95 | 93 | let pmt = extract(i.payment) | |
96 | 94 | let playerAddress = toString(i.caller) | |
97 | 95 | let betNotInWaves = isDefined(pmt.assetId) | |
98 | 96 | let feeNotInWaves = isDefined(pmt.assetId) | |
99 | 97 | let donateAmt = pmt.amount | |
100 | 98 | if (betNotInWaves) | |
101 | 99 | then throw("Bet amount must be in Waves") | |
102 | 100 | else if (feeNotInWaves) | |
103 | 101 | then throw("Transaction's fee must be in Waves") | |
104 | 102 | else { | |
105 | 103 | let donateAmtValid = if (if (if (if (if (if ((donateAmt == (Bag1 + COMMISSION))) | |
106 | 104 | then true | |
107 | 105 | else (donateAmt == (Bag5 + COMMISSION))) | |
108 | 106 | then true | |
109 | 107 | else (donateAmt == (Bag10 + COMMISSION))) | |
110 | 108 | then true | |
111 | 109 | else (donateAmt == (Bag20 + COMMISSION))) | |
112 | 110 | then true | |
113 | 111 | else (donateAmt == (Bag50 + COMMISSION))) | |
114 | 112 | then true | |
115 | 113 | else (donateAmt == (Bag100 + COMMISSION))) | |
116 | 114 | then true | |
117 | 115 | else false | |
118 | 116 | if (donateAmtValid) | |
119 | 117 | then { | |
120 | 118 | let donateNum = ((donateAmt - COMMISSION) / WAVELET) | |
121 | 119 | let key2Balance = (playerAddress + "_balance") | |
122 | 120 | let newBalance = (getBalance(key2Balance) + (donateNum * TokenPrice)) | |
123 | 121 | let donateData = [DataEntry(DONATECOUNTERKEY, newGameNum), DataEntry(key2Balance, newBalance), DataEntry(donateId, donateNum)] | |
124 | 122 | WriteSet(donateData) | |
125 | 123 | } | |
126 | 124 | else throw("You paid the wrong amount") | |
127 | 125 | } | |
128 | 126 | } | |
129 | 127 | ||
130 | 128 | ||
131 | 129 | @Verifier(tx) | |
132 | 130 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
133 | 131 | then match tx { | |
134 | 132 | case ttx: TransferTransaction => | |
135 | 133 | true | |
136 | 134 | case stx: SetScriptTransaction => | |
137 | 135 | true | |
138 | 136 | case _ => | |
139 | 137 | false | |
140 | 138 | } | |
141 | 139 | else false | |
142 | 140 |
github/deemru/w8io/026f985 38.09 ms ◑