tx · 7ZZ3RuXYWWyAVkbVSeWfAkPcUZ2h7iQe1A2CbYR6ATar 3Mu8oKScWCwR33YomT5ukU73P7jLryZTk4s: -0.01400000 Waves 2019.07.03 10:57 [568962] smart account 3Mu8oKScWCwR33YomT5ukU73P7jLryZTk4s > SELF 0.00000000 Waves
{ "type": 13, "id": "7ZZ3RuXYWWyAVkbVSeWfAkPcUZ2h7iQe1A2CbYR6ATar", "fee": 1400000, "feeAssetId": null, "timestamp": 1562140672946, "version": 1, "sender": "3Mu8oKScWCwR33YomT5ukU73P7jLryZTk4s", "senderPublicKey": "DrYgfD7j6AKD1iXtn9uhMka95ATZB42B1kGKCUATP2UG", "proofs": [ "oVb4RJx6aRsWnGWdgYB2BEem5xkHJVSt2Xs5MCKDN1D5h3NPVTj5UGyTxfyZVLYrVFxbtr8ZENj3z2zU6pDMMKX" ], "script": "base64:AAIDAAAAAAAAAAAAAAAnAAAAAA9TZXJ2ZXJQdWJsaWNLZXkBAAAAIL79hxhmqWX34iA/RS9p36FY3qCJjLclClmAz4vj6GlBAAAAAA1TZXJ2ZXJBZGRyZXNzCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNNdThvS1NjV0N3UjMzWW9tVDV1a1U3M1A3akxyeVpUazRzAAAAABBSb3VsZXR0ZVNlY3Rpb25zAAAAAAAAAAAVAAAAABFEYXRhR2FtZU51bWJlcktleQIAAAALQVBQX0dBTUVfSUQAAAAADURhdGFBbW91bnRLZXkCAAAABkFNT1VOVAAAAAAORGF0YVNlY3Rpb25LZXkCAAAAB1NFQ1RJT04AAAAADURhdGFTdGF0dXNLZXkCAAAABlNUQVRVUwAAAAANRGF0YVJlc3VsdEtleQIAAAAGUkVTVUxUAAAAABBEYXRhV2luQW1vdW50S2V5AgAAAApXSU5fQU1PVU5UAAAAAA1EYXRhU3RhdHVzTmV3AgAAAANORVcAAAAADURhdGFTdGF0dXNXaW4CAAAAA1dJTgAAAAAPRGF0YVN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QAAAAEFAAAABndhbGxldAUAAAAJd2luQW1vdW50BQAAAAR1bml0BQAAAANuaWwFAAAACHdyaXRlU2V0CQAAAgAAAAEJAAEsAAAAAgUAAAANRXJyb3JHYW1lT3ZlcgUAAAAGc3RhdHVzAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAMJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAADdHR4BQAAAAckbWF0Y2gwBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAA3N0eAUAAAAHJG1hdGNoMAYHB5R5uoU=", "chainId": 84, "height": 568962, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let ServerPublicKey = base58'DrYgfD7j6AKD1iXtn9uhMka95ATZB42B1kGKCUATP2UG' | |
5 | + | ||
6 | + | let ServerAddress = addressFromStringValue("3Mu8oKScWCwR33YomT5ukU73P7jLryZTk4s") | |
7 | + | ||
8 | + | let RouletteSections = 21 | |
9 | + | ||
10 | + | let DataGameNumberKey = "APP_GAME_ID" | |
11 | + | ||
12 | + | let DataAmountKey = "AMOUNT" | |
13 | + | ||
14 | + | let DataSectionKey = "SECTION" | |
15 | + | ||
16 | + | let DataStatusKey = "STATUS" | |
17 | + | ||
18 | + | let DataResultKey = "RESULT" | |
19 | + | ||
20 | + | let DataWinAmountKey = "WIN_AMOUNT" | |
21 | + | ||
22 | + | let DataStatusNew = "NEW" | |
23 | + | ||
24 | + | let DataStatusWin = "WIN" | |
25 | + | ||
26 | + | let DataStatusLoose = "LOOSE" | |
27 | + | ||
28 | + | let WAVELET = ((100 * 1000) * 1000) | |
29 | + | ||
30 | + | let COMMISSION = ((5 * WAVELET) / 1000) | |
31 | + | ||
32 | + | let BET1 = (1 * WAVELET) | |
33 | + | ||
34 | + | let BET2 = (2 * WAVELET) | |
35 | + | ||
36 | + | let BET4 = (4 * WAVELET) | |
37 | + | ||
38 | + | let BET8 = (8 * WAVELET) | |
39 | + | ||
40 | + | let BET14 = (14 * WAVELET) | |
41 | + | ||
42 | + | let Sections = [0, 2, 20, 2, 5, 2, 10, 2, 6, 2, 5, 2, 6, 2, 5, 2, 10, 2, 5, 2, 6] | |
43 | + | ||
44 | + | let ErrorOnlyWavesAccepted = "Only waves accepted" | |
45 | + | ||
46 | + | let ErrorMustGreaterThan0 = "Parameter size must be greater than 0" | |
47 | + | ||
48 | + | let ErrorMustLessThan100 = "Parameter size must be less than 100" | |
49 | + | ||
50 | + | let ErrorBetMustBeInWaves = "Bet amount must be in Waves" | |
51 | + | ||
52 | + | let ErrorTransactionMustBeInWaves = "Transaction's fee must be in Waves" | |
53 | + | ||
54 | + | let ErrorTransactionUsed = "Passed txId had been used before. Game aborted." | |
55 | + | ||
56 | + | let ErrorKeyNotFound = "Key not found: " | |
57 | + | ||
58 | + | let ErrorGameOver = "Game already is over " | |
59 | + | ||
60 | + | let ErrorIncorrectSectionResult = "Incorrect section result" | |
61 | + | ||
62 | + | let ErrorBetAmountNotInRange = "Bet amount is not in range" | |
63 | + | ||
64 | + | func StoreData (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value) | |
65 | + | ||
66 | + | ||
67 | + | func StoreDataInt (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value) | |
68 | + | ||
69 | + | ||
70 | + | func GetData (key) = match getString(this, key) { | |
71 | + | case str: String => | |
72 | + | str | |
73 | + | case _ => | |
74 | + | throw((ErrorKeyNotFound + key)) | |
75 | + | } | |
76 | + | ||
77 | + | ||
78 | + | func GetDataString (transactionId,key) = { | |
79 | + | let fullKey = ((transactionId + "_") + key) | |
80 | + | match getString(this, fullKey) { | |
81 | + | case str: String => | |
82 | + | str | |
83 | + | case _ => | |
84 | + | throw((ErrorKeyNotFound + fullKey)) | |
85 | + | } | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | func GetDataInt (transactionId,key) = { | |
90 | + | let fullKey = ((transactionId + "_") + key) | |
91 | + | match getInteger(this, fullKey) { | |
92 | + | case str: Int => | |
93 | + | str | |
94 | + | case _ => | |
95 | + | throw((ErrorKeyNotFound + fullKey)) | |
96 | + | } | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | func NewGameId () = { | |
101 | + | let gameNum = match getInteger(this, DataGameNumberKey) { | |
102 | + | case num: Int => | |
103 | + | num | |
104 | + | case _ => | |
105 | + | 0 | |
106 | + | } | |
107 | + | (gameNum + 1) | |
108 | + | } | |
109 | + | ||
110 | + | ||
111 | + | func GenerateRandInt (gameId,rsaSign) = { | |
112 | + | let rsaSigValid = sigVerify(fromBase58String(gameId), fromBase58String(rsaSign), ServerPublicKey) | |
113 | + | if (rsaSigValid) | |
114 | + | then { | |
115 | + | let rand = (toInt(sha256(toBytes(rsaSign))) % RouletteSections) | |
116 | + | if ((0 > rand)) | |
117 | + | then (-1 * rand) | |
118 | + | else rand | |
119 | + | } | |
120 | + | else throw("Invalid RSA signature") | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func GetStatus (result) = if (result) | |
125 | + | then DataStatusWin | |
126 | + | else DataStatusLoose | |
127 | + | ||
128 | + | ||
129 | + | func GetWinAmount (betAmt,section) = { | |
130 | + | let isCorrectResult = if (if (if (if ((section == 2)) | |
131 | + | then true | |
132 | + | else (section == 5)) | |
133 | + | then true | |
134 | + | else (section == 6)) | |
135 | + | then true | |
136 | + | else (section == 10)) | |
137 | + | then true | |
138 | + | else (section == 20) | |
139 | + | let betAmtValid = if (if (if (if ((betAmt == (BET1 + COMMISSION))) | |
140 | + | then true | |
141 | + | else (betAmt == (BET2 + COMMISSION))) | |
142 | + | then true | |
143 | + | else (betAmt == (BET4 + COMMISSION))) | |
144 | + | then true | |
145 | + | else (betAmt == (BET8 + COMMISSION))) | |
146 | + | then true | |
147 | + | else (betAmt == (BET14 + COMMISSION)) | |
148 | + | if (!(isCorrectResult)) | |
149 | + | then throw(ErrorIncorrectSectionResult) | |
150 | + | else if (betAmtValid) | |
151 | + | then ((betAmt - COMMISSION) * section) | |
152 | + | else throw(ErrorBetAmountNotInRange) | |
153 | + | } | |
154 | + | ||
155 | + | ||
156 | + | @Callable(i) | |
157 | + | func bet (expectedResult) = { | |
158 | + | let gameNumber = NewGameId() | |
159 | + | let gameTransactionId = toBase58String(i.transactionId) | |
160 | + | let address = toBase58String(i.caller.bytes) | |
161 | + | let pmt = extract(i.payment) | |
162 | + | let txIdUsed = isDefined(getString(this, gameTransactionId)) | |
163 | + | let betNotInWaves = isDefined(pmt.assetId) | |
164 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
165 | + | let amount = pmt.amount | |
166 | + | let winAmt = GetWinAmount(pmt.amount, expectedResult) | |
167 | + | if (betNotInWaves) | |
168 | + | then throw(ErrorBetMustBeInWaves) | |
169 | + | else if (feeNotInWaves) | |
170 | + | then throw(ErrorTransactionMustBeInWaves) | |
171 | + | else if (txIdUsed) | |
172 | + | then throw(ErrorTransactionUsed) | |
173 | + | else ScriptResult(WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, gameNumber), StoreDataInt(gameTransactionId, DataAmountKey, amount), StoreDataInt(gameTransactionId, DataSectionKey, expectedResult), StoreData(gameTransactionId, DataStatusKey, DataStatusNew), StoreDataInt(gameTransactionId, DataWinAmountKey, winAmt)]), TransferSet([ScriptTransfer(ServerAddress, COMMISSION, unit)])) | |
174 | + | } | |
175 | + | ||
176 | + | ||
177 | + | ||
178 | + | @Callable(i) | |
179 | + | func result (gameTransactionId,rsa) = { | |
180 | + | let randIndex = GenerateRandInt(gameTransactionId, rsa) | |
181 | + | let selectedSection = GetDataInt(gameTransactionId, DataSectionKey) | |
182 | + | let status = GetDataString(gameTransactionId, DataStatusKey) | |
183 | + | if ((status == DataStatusNew)) | |
184 | + | then { | |
185 | + | let randSection = Sections[randIndex] | |
186 | + | let isWin = (randSection == selectedSection) | |
187 | + | let writeSet = WriteSet([StoreData(gameTransactionId, DataStatusKey, GetStatus(isWin)), StoreDataInt(gameTransactionId, DataResultKey, randSection)]) | |
188 | + | if (isWin) | |
189 | + | then { | |
190 | + | let wallet = GetData(gameTransactionId) | |
191 | + | let winAmount = GetDataInt(gameTransactionId, DataWinAmountKey) | |
192 | + | ScriptResult(writeSet, TransferSet([ScriptTransfer(addressFromStringValue(wallet), winAmount, unit)])) | |
193 | + | } | |
194 | + | else writeSet | |
195 | + | } | |
196 | + | else throw((ErrorGameOver + status)) | |
197 | + | } | |
198 | + | ||
199 | + | ||
200 | + | @Verifier(tx) | |
201 | + | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
202 | + | then match tx { | |
203 | + | case ttx: TransferTransaction => | |
204 | + | true | |
205 | + | case stx: SetScriptTransaction => | |
206 | + | true | |
207 | + | case _ => | |
208 | + | false | |
209 | + | } | |
210 | + | else false | |
211 | + |
github/deemru/w8io/169f3d6 25.97 ms ◑