tx · 4vBWRhoh2qb5iSri55czCtQBfNSx8RLca2T18g7CV3s9 3N9fzexZxi7HrPcfizpvpFcaAnvpyuuMKPg: -0.01400000 Waves 2019.08.27 23:30 [650080] smart account 3N9fzexZxi7HrPcfizpvpFcaAnvpyuuMKPg > SELF 0.00000000 Waves
{ "type": 13, "id": "4vBWRhoh2qb5iSri55czCtQBfNSx8RLca2T18g7CV3s9", "fee": 1400000, "feeAssetId": null, "timestamp": 1566937883772, "version": 1, "sender": "3N9fzexZxi7HrPcfizpvpFcaAnvpyuuMKPg", "senderPublicKey": "BJB5QS4iQna1z8idKb5QQ5cACUmNgxzHc81Y7AW6ZZY7", "proofs": [ "3ovhiXEds13qi4HDWHw882zVZRHQvWtHFpQ5jhVCCnczZHP9jWzg9qEyvwAh29MyR38GYBfMkT4c1Ch9AbWYxPbD" ], "script": "base64:AAIDAAAAAAAAAAAAAAAGAAAAABBzdGFydFJvdW5kSGVpZ2h0AAAAAAAAAAAFAQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAACGxhc3RQbGF5BAAAAAckbWF0Y2gwCQAEHAAAAAIFAAAABHRoaXMCAAAACGxhc3RQbGF5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0BAAAAAFhBQAAAAckbWF0Y2gwAQAAAAxXYXZlc0xvdHRvVjIJAQAAAAV0aHJvdwAAAAAEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACBQAAAAhsYXN0UGxheQgFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABmgAAA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Sb3VuZAIAAAAOX2NvdW50R2FtZXJzVXADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABZwUAAAAHJG1hdGNoMAUAAAABZwAAAAAAAAAAAAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAAMY3VycmVudFJvdW5kAgAAAAZfbW9yZV8FAAAADGFkZHJlc3NHYW1lcggFAAAAA3BtdAAAAAZhbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAAaQAAAABBQAAAAxjdXJyZW50Um91bmQCAAAADl9jb3VudEdhbWVyc1VwCQAAZAAAAAIFAAAAEG51bWJlck9mR2FtZXJzVXAAAAAAAAAAAAEFAAAAA25pbAMJAABmAAAAAgUAAAAIY291bnRCZXQIBQAAAANwbXQAAAAGYW1vdW50CQAAAgAAAAECAAAAI1BheW1lbnQgbXVzdCBiZSBtb3JlIGZvciB0aGUgcm91bmQhCQAAAgAAAAECAAAAFXdvcmtzIHdpdGggd2F2ZXMgb25seQAAAABcsyWP", "chainId": 84, "height": 650080, "spentComplexity": 0 } View: original | compacted Prev: 1j3JjfzFmJEGkgUzCgT7DrsaP5D8f5EjtZ4AjvvZiiP Next: 46ogj69H7LC1d1DmUAz8sX9KrnVWkToDb2rfraTNYPPW Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let startRoundHeight = 5 | |
5 | 5 | ||
6 | 6 | func randomizer (inv) = { | |
7 | 7 | let lastPlay = match getBinary(this, "lastPlay") { | |
8 | 8 | case s: ByteVector => | |
9 | 9 | s | |
10 | 10 | case a: Unit => | |
11 | 11 | base58'2ee4oFDYriWJ9EMeR' | |
12 | 12 | case _ => | |
13 | 13 | throw() | |
14 | 14 | } | |
15 | 15 | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
16 | 16 | sha256(rand) | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func setWinnersPrevRound (currRound,randhash) = { | |
21 | 21 | let prevNumberRound = (currRound - 1) | |
22 | 22 | if ((randhash > 500)) | |
23 | 23 | then WriteSet([DataEntry("lastRoundWinner", (toString(prevNumberRound) + "_more_")), DataEntry("numberRound", currRound), DataEntry("startGame", true), DataEntry("randhash", randhash)]) | |
24 | 24 | else WriteSet([DataEntry("lastRoundWinner", (toString(prevNumberRound) + "_less_")), DataEntry("numberRound", currRound), DataEntry("startGame", true), DataEntry("randhash", randhash)]) | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getCurrentNumberRound () = match getInteger(this, "numberRound") { | |
29 | 29 | case a: Int => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | 1 | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getBet (bet,round,addressGamer) = if ((round >= 1)) | |
37 | 37 | then { | |
38 | 38 | let winnerOfPrevRound = match getString(this, "lastRoundWinner") { | |
39 | 39 | case w: String => | |
40 | 40 | w | |
41 | 41 | case _ => | |
42 | 42 | "" | |
43 | 43 | } | |
44 | 44 | let winnerFromPrevRound = match getString(this, (winnerOfPrevRound + addressGamer)) { | |
45 | 45 | case w: String => | |
46 | 46 | w | |
47 | 47 | case _ => | |
48 | 48 | "" | |
49 | 49 | } | |
50 | 50 | if (if ((round > 1)) | |
51 | 51 | then (winnerFromPrevRound == "") | |
52 | 52 | else false) | |
53 | 53 | then (round * 2) | |
54 | 54 | else 1 | |
55 | 55 | } | |
56 | 56 | else 1 | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func getNumberGame () = match getInteger(this, "numberGame") { | |
60 | 60 | case a: Int => | |
61 | 61 | (a + 1) | |
62 | 62 | case _ => | |
63 | 63 | 1 | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | @Callable(i) | |
68 | 68 | func startRound () = { | |
69 | 69 | let newNumberOfRound = match getInteger(this, "numberRound") { | |
70 | 70 | case a: Int => | |
71 | 71 | (a + 1) | |
72 | 72 | case _ => | |
73 | 73 | 1 | |
74 | 74 | } | |
75 | 75 | let randhash = randomizer(i) | |
76 | 76 | let isGameStarted = match getBoolean(this, "startGame") { | |
77 | 77 | case g: Boolean => | |
78 | 78 | g | |
79 | 79 | case _ => | |
80 | 80 | false | |
81 | 81 | } | |
82 | 82 | if (if (if ((newNumberOfRound == 1)) | |
83 | 83 | then (i.caller == this) | |
84 | 84 | else false) | |
85 | 85 | then !(isGameStarted) | |
86 | 86 | else false) | |
87 | 87 | then { | |
88 | 88 | let newNumberGame = getNumberGame() | |
89 | 89 | WriteSet([DataEntry("numberGame", newNumberGame), DataEntry("startGame", !(isGameStarted)), DataEntry("numberRound", newNumberOfRound)]) | |
90 | 90 | } | |
91 | 91 | else if (if ((newNumberOfRound > 1)) | |
92 | 92 | then (i.caller == this) | |
93 | 93 | else false) | |
94 | 94 | then setWinnersPrevRound(newNumberOfRound, (toInt(randhash) % 1000)) | |
95 | 95 | else throw("Only owner can start the game.") | |
96 | 96 | } | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | 100 | @Callable(i) | |
101 | 101 | func forwardRound () = { | |
102 | 102 | let isGameStarted = match getBoolean(this, "startGame") { | |
103 | 103 | case g: Boolean => | |
104 | 104 | g | |
105 | 105 | case _ => | |
106 | 106 | false | |
107 | 107 | } | |
108 | 108 | let newNumberOfRound = match getInteger(this, "numberRound") { | |
109 | 109 | case a: Int => | |
110 | 110 | a | |
111 | 111 | case _ => | |
112 | 112 | 1 | |
113 | 113 | } | |
114 | 114 | let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) { | |
115 | 115 | case g: Int => | |
116 | 116 | g | |
117 | 117 | case _ => | |
118 | 118 | 0 | |
119 | 119 | } | |
120 | 120 | let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) { | |
121 | 121 | case g: Int => | |
122 | 122 | g | |
123 | 123 | case _ => | |
124 | 124 | 0 | |
125 | 125 | } | |
126 | 126 | if (if (if (if ((numberOfGamersUp > 0)) | |
127 | 127 | then (i.caller == this) | |
128 | 128 | else false) | |
129 | 129 | then isGameStarted | |
130 | 130 | else false) | |
131 | 131 | then (numberOfGamersDown > 0) | |
132 | 132 | else false) | |
133 | 133 | then WriteSet([DataEntry("startGame", !(isGameStarted))]) | |
134 | 134 | else throw("Only owner can start the game.") | |
135 | 135 | } | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | ||
139 | 139 | @Callable(i) | |
140 | 140 | func makeBetLess () = { | |
141 | 141 | let pmt = extract(i.payment) | |
142 | 142 | let addressGamer = toBase58String(i.caller.bytes) | |
143 | 143 | let currentRound = getCurrentNumberRound() | |
144 | 144 | let countBet = getBet(pmt.amount, currentRound, addressGamer) | |
145 | 145 | if (if (!(isDefined(pmt.assetId))) | |
146 | 146 | then (pmt.amount >= countBet) | |
147 | 147 | else false) | |
148 | 148 | then { | |
149 | 149 | let newNumberOfRound = match getInteger(this, "numberRound") { | |
150 | 150 | case a: Int => | |
151 | 151 | a | |
152 | 152 | case _ => | |
153 | 153 | 1 | |
154 | 154 | } | |
155 | 155 | let numberOfGamersDown = match getInteger(this, (toString(newNumberOfRound) + "_countGamersDown")) { | |
156 | 156 | case g: Int => | |
157 | 157 | g | |
158 | 158 | case _ => | |
159 | 159 | 0 | |
160 | 160 | } | |
161 | 161 | WriteSet([DataEntry(((toString(currentRound) + "_less_") + addressGamer), pmt.amount), DataEntry((toString(currentRound) + "_countGamersDown"), (numberOfGamersDown + 1))]) | |
162 | 162 | } | |
163 | 163 | else if ((countBet > pmt.amount)) | |
164 | 164 | then throw("Payment must be more for the round!") | |
165 | 165 | else throw("works with waves only") | |
166 | 166 | } | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
170 | 170 | @Callable(i) | |
171 | 171 | func makeBetMore () = { | |
172 | 172 | let pmt = extract(i.payment) | |
173 | 173 | let addressGamer = toBase58String(i.caller.bytes) | |
174 | 174 | let currentRound = getCurrentNumberRound() | |
175 | 175 | let countBet = getBet(pmt.amount, currentRound, addressGamer) | |
176 | 176 | if (if (!(isDefined(pmt.assetId))) | |
177 | 177 | then (pmt.amount >= countBet) | |
178 | 178 | else false) | |
179 | 179 | then { | |
180 | 180 | let newNumberOfRound = match getInteger(this, "numberRound") { | |
181 | 181 | case a: Int => | |
182 | 182 | a | |
183 | 183 | case _ => | |
184 | 184 | 1 | |
185 | 185 | } | |
186 | 186 | let numberOfGamersUp = match getInteger(this, (toString(newNumberOfRound) + "_countGamersUp")) { | |
187 | 187 | case g: Int => | |
188 | 188 | g | |
189 | 189 | case _ => | |
190 | 190 | 0 | |
191 | 191 | } | |
192 | 192 | WriteSet([DataEntry(((toString(currentRound) + "_more_") + addressGamer), pmt.amount), DataEntry((toString(currentRound) + "_countGamersUp"), (numberOfGamersUp + 1))]) | |
193 | 193 | } | |
194 | 194 | else if ((countBet > pmt.amount)) | |
195 | 195 | then throw("Payment must be more for the round!") | |
196 | 196 | else throw("works with waves only") | |
197 | 197 | } | |
198 | 198 | ||
199 | 199 |
github/deemru/w8io/026f985 28.63 ms ◑