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