tx · 4qmcCnWVMZvQTufm9pyJ9wWEfX87qxT3TYMtsNQWSAMN 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs: -0.01400000 Waves 2019.08.27 23:33 [650084] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves
{ "type": 13, "id": "4qmcCnWVMZvQTufm9pyJ9wWEfX87qxT3TYMtsNQWSAMN", "fee": 1400000, "feeAssetId": null, "timestamp": 1566938021162, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "M5zAdJyHjJiJnmmS23k1csLDAtAhfsWY82wazQpnJZa6b6LK6fhk5yomP4C9Zj1aCJts7oSnGTTgn7D5LFA1qAu" ], "script": "base64:AAIDAAAAAAAAAAAAAAAQAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAAClRva2VuUHJpY2UAAAAAAAAAAAoAAAAAEERPTkFURUNPVU5URVJLRVkCAAAACyRET05BVEVfTlVNAAAAAAdCVVlJVEVNAgAAAAkkQlVZX0lURU0AAAAABEJhZzEJAABoAAAAAgAAAAAAAAAAAQUAAAAHV0FWRUxFVAAAAAAEQmFnNQkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAVCYWcxMAkAAGgAAAACAAAAAAAAAAAKBQAAAAdXQVZFTEVUAAAAAAVCYWcyMAkAAGgAAAACAAAAAAAAAAAUBQAAAAdXQVZFTEVUAAAAAAVCYWc1MAkAAGgAAAACAAAAAAAAAAAyBQAAAAdXQVZFTEVUAAAAAAZCYWcxMDAJAABoAAAAAgAAAAAAAAAAZAU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CeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAADdHR4BQAAAAckbWF0Y2gwBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAA3N0eAUAAAAHJG1hdGNoMAYHB+dCXQ0=", "chainId": 84, "height": 650084, "spentComplexity": 0 } View: original | compacted Prev: Hk6M1LK5mbsjVd9jwSDM9kKpxDi4JM2VQUKPmSt3ZcSh Next: 32kGkj89KUW4ci8NGuHUXTBrGhMScP865vLDZBkySyhT Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | case int: Int => | |
71 | 71 | toString(int) | |
72 | 72 | case _ => | |
73 | - | "found" | |
73 | + | "not found" | |
74 | 74 | } | |
75 | 75 | rawDataStr | |
76 | 76 | } |
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 | func IncrementDonateNum () = { | |
27 | 27 | let gameNum = match getInteger(this, DONATECOUNTERKEY) { | |
28 | 28 | case num: Int => | |
29 | 29 | num | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | (gameNum + 1) | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getBalance (key) = { | |
38 | 38 | let playerBalanceNum = match getInteger(this, key) { | |
39 | 39 | case playerBalanceNum: Int => | |
40 | 40 | playerBalanceNum | |
41 | 41 | case _ => | |
42 | 42 | 0 | |
43 | 43 | } | |
44 | 44 | playerBalanceNum | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func ExtractItemsList (key) = { | |
49 | 49 | let rawDataStr = match getString(this, key) { | |
50 | 50 | case str: String => | |
51 | 51 | str | |
52 | 52 | case _ => | |
53 | 53 | "" | |
54 | 54 | } | |
55 | 55 | rawDataStr | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func getPriceByItemID (itemId) = if ((itemId == "1")) | |
60 | 60 | then 1 | |
61 | 61 | else if ((itemId == "2")) | |
62 | 62 | then 4 | |
63 | 63 | else if ((itemId == "3")) | |
64 | 64 | then 6 | |
65 | 65 | else throw("Неверный ID item") | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func isItemExist (oldItemsList,itemId) = { | |
69 | 69 | let rawDataStr = match indexOf(oldItemsList, (itemId + ":")) { | |
70 | 70 | case int: Int => | |
71 | 71 | toString(int) | |
72 | 72 | case _ => | |
73 | - | "found" | |
73 | + | "not found" | |
74 | 74 | } | |
75 | 75 | rawDataStr | |
76 | 76 | } | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | @Callable(i) | |
80 | 80 | func buy (itemId) = { | |
81 | 81 | let buyTXId = toBase58String(i.transactionId) | |
82 | 82 | let playerAddress = toString(i.caller) | |
83 | 83 | let key2Items = (playerAddress + "_items") | |
84 | 84 | let balanceMinus = getPriceByItemID(itemId) | |
85 | 85 | let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus) | |
86 | 86 | let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance) | |
87 | 87 | let oldItemsList = ExtractItemsList(key2Items) | |
88 | 88 | let searchResult = isItemExist(oldItemsList, itemId) | |
89 | 89 | if ((searchResult == "")) | |
90 | 90 | then throw("This item not exist") | |
91 | 91 | else throw(searchResult) | |
92 | 92 | } | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
96 | 96 | @Callable(i) | |
97 | 97 | func reset () = { | |
98 | 98 | let playerAddress = toString(i.caller) | |
99 | 99 | let donateData = [DataEntry(DONATECOUNTERKEY, 0), DataEntry((playerAddress + "_balance"), 0)] | |
100 | 100 | WriteSet(donateData) | |
101 | 101 | } | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Callable(i) | |
106 | 106 | func donate () = { | |
107 | 107 | let newGameNum = IncrementDonateNum() | |
108 | 108 | let donateId = toBase58String(i.transactionId) | |
109 | 109 | let pmt = extract(i.payment) | |
110 | 110 | let playerAddress = toString(i.caller) | |
111 | 111 | let betNotInWaves = isDefined(pmt.assetId) | |
112 | 112 | let feeNotInWaves = isDefined(pmt.assetId) | |
113 | 113 | let donateAmt = pmt.amount | |
114 | 114 | if (betNotInWaves) | |
115 | 115 | then throw("Bet amount must be in Waves") | |
116 | 116 | else if (feeNotInWaves) | |
117 | 117 | then throw("Transaction's fee must be in Waves") | |
118 | 118 | else { | |
119 | 119 | let donateAmtValid = if (if (if (if (if (if ((donateAmt == (Bag1 + COMMISSION))) | |
120 | 120 | then true | |
121 | 121 | else (donateAmt == (Bag5 + COMMISSION))) | |
122 | 122 | then true | |
123 | 123 | else (donateAmt == (Bag10 + COMMISSION))) | |
124 | 124 | then true | |
125 | 125 | else (donateAmt == (Bag20 + COMMISSION))) | |
126 | 126 | then true | |
127 | 127 | else (donateAmt == (Bag50 + COMMISSION))) | |
128 | 128 | then true | |
129 | 129 | else (donateAmt == (Bag100 + COMMISSION))) | |
130 | 130 | then true | |
131 | 131 | else false | |
132 | 132 | if (donateAmtValid) | |
133 | 133 | then { | |
134 | 134 | let donateNum = ((donateAmt - COMMISSION) / WAVELET) | |
135 | 135 | let key2Balance = (playerAddress + "_balance") | |
136 | 136 | let newBalance = (getBalance(key2Balance) + (donateNum * TokenPrice)) | |
137 | 137 | let donateData = [DataEntry(DONATECOUNTERKEY, newGameNum), DataEntry(key2Balance, newBalance), DataEntry(donateId, donateNum)] | |
138 | 138 | WriteSet(donateData) | |
139 | 139 | } | |
140 | 140 | else throw("You paid the wrong amount") | |
141 | 141 | } | |
142 | 142 | } | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | @Verifier(tx) | |
146 | 146 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
147 | 147 | then match tx { | |
148 | 148 | case ttx: TransferTransaction => | |
149 | 149 | true | |
150 | 150 | case stx: SetScriptTransaction => | |
151 | 151 | true | |
152 | 152 | case _ => | |
153 | 153 | false | |
154 | 154 | } | |
155 | 155 | else false | |
156 | 156 |
github/deemru/w8io/026f985 27.48 ms ◑