tx · A1ck512fybHMZivTSc3Jj7dqSnekfMcVsQkHubqCM1Yj 3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE: -0.01500000 Waves 2019.07.12 13:19 [582377] smart account 3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE > SELF 0.00000000 Waves
{ "type": 13, "id": "A1ck512fybHMZivTSc3Jj7dqSnekfMcVsQkHubqCM1Yj", "fee": 1500000, "feeAssetId": null, "timestamp": 1562926772098, "version": 1, "sender": "3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE", "senderPublicKey": "8fdATo5z3B5EweA3kKoRgbJZhGa4JicyHHMkhBZTvNSf", "proofs": [ "2nsDdmeA6DSgLNMkiNLGU9vm6TBug2iBCCG4PvprZRjVTVbqg2PE8jikm5ZcFxDH4oL3RfFZA5Z8GtcEAUr78VwC" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAVXYXZlcwAAAAAABfXhAAAAAAAEYmV0MQkAAGgAAAACAAAAAAAAAAABBQAAAAVXYXZlcwAAAAAEYmV0NQkAAGgAAAACAAAAAAAAAAAFBQAAAAVXYXZlcwAAAAAFYmV0MTAJAABoAAAAAgAAAAAAAAAACgUAAAAFV2F2ZXMAAAAABWJldDI1CQAAaAAAAAIAAAAAAAAAABkFAAAABVdhdmVzAAAAAAZiZXQxMDAJAABoAAAAAgAAAAAAAAAAZAUAAAAFV2F2ZXMAAAAACWNvbWlzc2lvbgAAAAAAAExLQAAAAAAPb3JhY2xlUHVibGljS2V5CQACWwAAAAECAAAAh2Jhc2U2NDpNRnd3RFFZSktvWklodmNOQVFFQkJRQURTd0F3U0FKQkFNWnVMb0xIVjVmY3VxUC9LakhvUTZWc1pTa1NXRjJBd1JBTHJMZ1RVZlhZc2RKdzF6djB0OXY3SUhSNjNnN1lyb0N2VUZTWG0xUm1PaFMxWGpyNXlJRUNBd0VBQVE9PQAAAAANZ2FtZVRpbWVGcmFtZQAAAAAAAAAFoAAAAAAIc3RhdGVBY2MCAAAACEFjY2Vw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AAAAA9yZXNlcnZlZEJhbGFuY2UEAAAAByRtYXRjaDEFAAAAFHZhbHVlUmVzZXJ2ZWRCYWxhbmNlAwkAAAEAAAACBQAAAAckbWF0Y2gxAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDEFAAAAAWEAAAAAAAAAAAAEAAAAEGF2YWlsYWJsZUJhbGFuY2UJAABlAAAAAgkBAAAADHdhdmVzQmFsYW5jZQAAAAEFAAAABHRoaXMFAAAAD3Jlc2VydmVkQmFsYW5jZQQAAAAPYXZhaWxpYmxlQW1vdW50CQAAZwAAAAIFAAAAEGF2YWlsYWJsZUJhbGFuY2UIBQAAAAN0dHgAAAAGYW1vdW50BAAAAAlzaWduYXR1cmUJAAH0AAAAAwgFAAAAA3R0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAA3R0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAN0dHgAAAAPc2VuZGVyUHVibGljS2V5AwUAAAAPYXZhaWxpYmxlQW1vdW50BQAAAAlzaWduYXR1cmUHAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAAEc3N0eAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAAEc3N0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAABHNzdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAAEc3N0eAAAAA9zZW5kZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAARpc3R4BQAAAAckbWF0Y2gwBgcg9rWN", "chainId": 84, "height": 582377, "spentComplexity": 0 } View: original | compacted Prev: 583C6WgyP1ukKL5QdAq4fLCkqMohvska3AjfMLeKw6YX Next: 27VSNnKyqfrNh4wCV1WFYtNqzJmPVGMxgG6S87qCmpr5 Diff:
Old | New | Differences | |
---|---|---|---|
15 | 15 | ||
16 | 16 | let comission = 5000000 | |
17 | 17 | ||
18 | - | let oraclePublicKey = "base64:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMZuLoLHV5fcuqP/KjHoQ6VsZSkSWF2A | |
19 | - | wRALrLgTUfXYsdJw1zv0t9v7IHR63g7YroCvUFSXm1RmOhS1Xjr5yIECAwEAAQ==" | |
18 | + | let oraclePublicKey = fromBase64String("base64:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMZuLoLHV5fcuqP/KjHoQ6VsZSkSWF2AwRALrLgTUfXYsdJw1zv0t9v7IHR63g7YroCvUFSXm1RmOhS1Xjr5yIECAwEAAQ==") | |
20 | 19 | ||
21 | 20 | let gameTimeFrame = 1440 | |
22 | 21 | ||
113 | 112 | } | |
114 | 113 | let playerChoice = dataList[2] | |
115 | 114 | let rsaToInt = { | |
116 | - | let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, | |
115 | + | let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, oraclePublicKey) | |
117 | 116 | if (rsaCheck) | |
118 | 117 | then { | |
119 | 118 | let rsaInt = ((toInt(sha256(rsaSign)) % 99) + 1) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let Waves = 100000000 | |
5 | 5 | ||
6 | 6 | let bet1 = (1 * Waves) | |
7 | 7 | ||
8 | 8 | let bet5 = (5 * Waves) | |
9 | 9 | ||
10 | 10 | let bet10 = (10 * Waves) | |
11 | 11 | ||
12 | 12 | let bet25 = (25 * Waves) | |
13 | 13 | ||
14 | 14 | let bet100 = (100 * Waves) | |
15 | 15 | ||
16 | 16 | let comission = 5000000 | |
17 | 17 | ||
18 | - | let oraclePublicKey = "base64:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMZuLoLHV5fcuqP/KjHoQ6VsZSkSWF2A | |
19 | - | wRALrLgTUfXYsdJw1zv0t9v7IHR63g7YroCvUFSXm1RmOhS1Xjr5yIECAwEAAQ==" | |
18 | + | let oraclePublicKey = fromBase64String("base64:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMZuLoLHV5fcuqP/KjHoQ6VsZSkSWF2AwRALrLgTUfXYsdJw1zv0t9v7IHR63g7YroCvUFSXm1RmOhS1Xjr5yIECAwEAAQ==") | |
20 | 19 | ||
21 | 20 | let gameTimeFrame = 1440 | |
22 | 21 | ||
23 | 22 | let stateAcc = "Accepted" | |
24 | 23 | ||
25 | 24 | let stateWin = "Win" | |
26 | 25 | ||
27 | 26 | let stateTimeout = "WinByTimeout" | |
28 | 27 | ||
29 | 28 | let stateLose = "Lose" | |
30 | 29 | ||
31 | 30 | @Callable(i) | |
32 | 31 | func bet (choice) = { | |
33 | 32 | let pmnt = extract(i.payment) | |
34 | 33 | let gameId = toBase58String(i.transactionId) | |
35 | 34 | let gameStart = height | |
36 | 35 | let gameCounter = { | |
37 | 36 | let gameNumber = { | |
38 | 37 | let counterValue = getInteger(this, "GamesCounter") | |
39 | 38 | match counterValue { | |
40 | 39 | case p: Int => | |
41 | 40 | p | |
42 | 41 | case _ => | |
43 | 42 | 0 | |
44 | 43 | } | |
45 | 44 | } | |
46 | 45 | (gameNumber + 1) | |
47 | 46 | } | |
48 | 47 | let betAssetIdCheck = isDefined(pmnt.assetId) | |
49 | 48 | let playerPublicKey = toBase58String(i.callerPublicKey) | |
50 | 49 | let playerChoice = if (if ((choice == "1")) | |
51 | 50 | then true | |
52 | 51 | else (choice == "2")) | |
53 | 52 | then choice | |
54 | 53 | else throw("Player's choice is incorrect") | |
55 | 54 | let playerPrize = { | |
56 | 55 | let bet = (pmnt.amount - comission) | |
57 | 56 | if (if (if (if (if ((bet == bet1)) | |
58 | 57 | then true | |
59 | 58 | else (bet == bet5)) | |
60 | 59 | then true | |
61 | 60 | else (bet == bet10)) | |
62 | 61 | then true | |
63 | 62 | else (bet == bet25)) | |
64 | 63 | then true | |
65 | 64 | else (bet == bet100)) | |
66 | 65 | then (bet * 2) | |
67 | 66 | else throw("Payment amount is incorrect") | |
68 | 67 | } | |
69 | 68 | let reservedBalance = { | |
70 | 69 | let currentReservedBalance = { | |
71 | 70 | let valueReservedBalance = getInteger(this, "Reserved") | |
72 | 71 | match valueReservedBalance { | |
73 | 72 | case a: Int => | |
74 | 73 | a | |
75 | 74 | case _ => | |
76 | 75 | 0 | |
77 | 76 | } | |
78 | 77 | } | |
79 | 78 | let newReservedBalance = (currentReservedBalance + playerPrize) | |
80 | 79 | if ((wavesBalance(this) >= newReservedBalance)) | |
81 | 80 | then { | |
82 | 81 | let increaseReservedBalance = newReservedBalance | |
83 | 82 | increaseReservedBalance | |
84 | 83 | } | |
85 | 84 | else throw("Bet was rejected. Insufficient funds on game account.") | |
86 | 85 | } | |
87 | 86 | if (betAssetIdCheck) | |
88 | 87 | then throw("You can make bet in Waves only") | |
89 | 88 | else { | |
90 | 89 | let dataString = ((((((((stateAcc + "_") + playerPublicKey) + "_") + playerChoice) + "_") + toString(playerPrize)) + "_") + toString(gameStart)) | |
91 | 90 | WriteSet([DataEntry("Reserved", reservedBalance), DataEntry(gameId, dataString)]) | |
92 | 91 | } | |
93 | 92 | } | |
94 | 93 | ||
95 | 94 | ||
96 | 95 | ||
97 | 96 | @Callable(i) | |
98 | 97 | func withdraw (gameId,rsaSign) = { | |
99 | 98 | let dataList = { | |
100 | 99 | let getDataString = getString(this, gameId) | |
101 | 100 | let a = match getDataString { | |
102 | 101 | case a: String => | |
103 | 102 | a | |
104 | 103 | case _ => | |
105 | 104 | throw("GameId was not found") | |
106 | 105 | } | |
107 | 106 | split(a, "_") | |
108 | 107 | } | |
109 | 108 | let gameState = dataList[0] | |
110 | 109 | let playerAddress = { | |
111 | 110 | let a = dataList[1] | |
112 | 111 | addressFromPublicKey(fromBase58String(a)) | |
113 | 112 | } | |
114 | 113 | let playerChoice = dataList[2] | |
115 | 114 | let rsaToInt = { | |
116 | - | let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, | |
115 | + | let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, oraclePublicKey) | |
117 | 116 | if (rsaCheck) | |
118 | 117 | then { | |
119 | 118 | let rsaInt = ((toInt(sha256(rsaSign)) % 99) + 1) | |
120 | 119 | if (if ((rsaInt > 0)) | |
121 | 120 | then (100 >= rsaInt) | |
122 | 121 | else false) | |
123 | 122 | then rsaInt | |
124 | 123 | else throw("Rsa integer is not in range") | |
125 | 124 | } | |
126 | 125 | else throw("Rsa Signature is invalid") | |
127 | 126 | } | |
128 | 127 | let gameStart = { | |
129 | 128 | let a = dataList[4] | |
130 | 129 | parseIntValue(a) | |
131 | 130 | } | |
132 | 131 | let playerPrize = { | |
133 | 132 | let a = dataList[3] | |
134 | 133 | parseIntValue(a) | |
135 | 134 | } | |
136 | 135 | let newReservedBalance = { | |
137 | 136 | let valueReservedBalance = getInteger(this, "Reserved") | |
138 | 137 | let extractReservedBalance = match valueReservedBalance { | |
139 | 138 | case a: Int => | |
140 | 139 | a | |
141 | 140 | case _ => | |
142 | 141 | 0 | |
143 | 142 | } | |
144 | 143 | let decreaseReservedBalance = (extractReservedBalance - playerPrize) | |
145 | 144 | if ((decreaseReservedBalance > 0)) | |
146 | 145 | then decreaseReservedBalance | |
147 | 146 | else throw("Reserved balance couldn't be less than 0") | |
148 | 147 | } | |
149 | 148 | let stringForNewData = ((((((dataList[1] + "_") + dataList[2]) + "_") + dataList[3]) + "_") + dataList[4]) | |
150 | 149 | let gameTime = (gameTimeFrame > (height - gameStart)) | |
151 | 150 | let stateCheck = (gameState == stateAcc) | |
152 | 151 | if (stateCheck) | |
153 | 152 | then if (gameTime) | |
154 | 153 | then { | |
155 | 154 | let playerWin = { | |
156 | 155 | let rsaToState = if ((48 > rsaToInt)) | |
157 | 156 | then "1" | |
158 | 157 | else if ((rsaToInt > 52)) | |
159 | 158 | then "2" | |
160 | 159 | else "3" | |
161 | 160 | (rsaToState == playerChoice) | |
162 | 161 | } | |
163 | 162 | if (playerWin) | |
164 | 163 | then ScriptResult(WriteSet([DataEntry(gameId, ((((stateWin + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)])) | |
165 | 164 | else WriteSet([DataEntry(gameId, ((((stateLose + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)]) | |
166 | 165 | } | |
167 | 166 | else throw("Game state is invalid") | |
168 | 167 | else ScriptResult(WriteSet([DataEntry(gameId, ((((stateTimeout + "_") + stringForNewData) + "_") + "00")), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)])) | |
169 | 168 | } | |
170 | 169 | ||
171 | 170 | ||
172 | 171 | @Verifier(tx) | |
173 | 172 | func verify () = match tx { | |
174 | 173 | case ttx: TransferTransaction => | |
175 | 174 | let valueReservedBalance = getInteger(this, "Reserved") | |
176 | 175 | let reservedBalance = match valueReservedBalance { | |
177 | 176 | case a: Int => | |
178 | 177 | a | |
179 | 178 | case _ => | |
180 | 179 | 0 | |
181 | 180 | } | |
182 | 181 | let availableBalance = (wavesBalance(this) - reservedBalance) | |
183 | 182 | let availibleAmount = (availableBalance >= ttx.amount) | |
184 | 183 | let signature = sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey) | |
185 | 184 | if (availibleAmount) | |
186 | 185 | then signature | |
187 | 186 | else false | |
188 | 187 | case sstx: SetScriptTransaction => | |
189 | 188 | sigVerify(sstx.bodyBytes, sstx.proofs[0], sstx.senderPublicKey) | |
190 | 189 | case istx: InvokeScriptTransaction => | |
191 | 190 | true | |
192 | 191 | case _ => | |
193 | 192 | false | |
194 | 193 | } | |
195 | 194 |
github/deemru/w8io/169f3d6 43.43 ms ◑