tx · rkk2us1fdwEDqcUhojN8xa3h6Qv5R7cRdGjttQyfdLT 3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE: -0.01400000 Waves 2019.09.08 14:44 [667060] smart account 3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE > SELF 0.00000000 Waves
{ "type": 13, "id": "rkk2us1fdwEDqcUhojN8xa3h6Qv5R7cRdGjttQyfdLT", "fee": 1400000, "feeAssetId": null, "timestamp": 1567943065556, "version": 1, "sender": "3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE", "senderPublicKey": "ESNVczQiY4oxY2hoRSZcruKNBwsPdXVu1nSCbpprDGJB", "proofs": [ "f7okUCcz3BD9ErfZVWTNjcUvcH43Q32Ao3wXuYMbRgEGAZQUgtwjE1FiUMjNKNng9J3oPa2aesVz6NpGZRzwYy1" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA9TZXJ2ZXJQdWJsaWNLZXkJAAJZAAAAAQIAAAAsN2ltOWNhaUNtRTRTTDZqVG00S1RpY0hINGJHUGY1djU5cm5mVUEzY0NSRGoAAAAACUJldFNlcnZlcgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTjZ5Rko1WjhOVVVRdmZHR01McDVlZm1ldlJSdFRnUXV1bgAAAAAHV0FWRUxFVAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAA+gAAAAAAAAAA+gAAAAACkNPTU1JU1NJT04JAABpAAAAAgkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAAAAAPoAAAAAA5UaWNrZXRzUGVyV2F2ZQAAAAAAAAAAZAAAAAALQ1VSUkVOVEdBTUUCAAAADSRDVVJSRU5UX0dBTUUAAAAACkxBU1RUSUNLRVQCAAAADCRMQVNUX1RJQ0tFVAEAAAAPR2VuZXJhdGVSYW5kSW50AAAAAgAAAAZnYW1lSWQAAAAHcnNhU2lnbgQAAAAKbGFzdFR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XN0AAAAAAAAAAAEAgAAAA1fdG90YWxCZXRzQW10CQAAAgAAAAECAAAABUVycm9yCQAAAgAAAAEJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAAEEN1cnJlbnQgR2FtZSBpcyAFAAAAC2N1cnJlbnRHYW1lAgAAAAosIGJ1dCBub3QgBQAAAAZnYW1lSWQAAAAAN9IoIw==", "chainId": 84, "height": 667060, "spentComplexity": 0 } View: original | compacted Prev: ATpPFcLMXmKvVMfWXYvgVqw3tCqYw8uCe15RKV6Nue6p Next: 89r6v9kA5zoUXPgEuRToAdKNkhwKPpkgo37EZmy6fPP1 Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let CURRENTGAME = "$CURRENT_GAME" | |
15 | 15 | ||
16 | 16 | let LASTTICKET = "$LAST_TICKET" | |
17 | - | ||
18 | - | let BANK = "$GAME_BANK" | |
19 | 17 | ||
20 | 18 | func GenerateRandInt (gameId,rsaSign) = { | |
21 | 19 | let lastTicket = getIntegerValue(BetServer, LASTTICKET) | |
70 | 68 | let winTicket = GenerateRandInt(gameId, rsaSign) | |
71 | 69 | let players = getStringValue(BetServer, (gameId + "_players")) | |
72 | 70 | let playersList = split(players, "_") | |
73 | - | let bankBalance = getIntegerValue(BetServer, BANK) | |
71 | + | let bankBalance = getIntegerValue(BetServer, (gameId + "_$GAME_BANK")) | |
74 | 72 | if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[0]) + "_tickets")), winTicket)) | |
75 | 73 | then win(gameId, winTicket, playersList[0], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[0]) + "_totalBetsAmt"))) | |
76 | 74 | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[1]) + "_tickets")), winTicket)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | 5 | ||
6 | 6 | let BetServer = addressFromStringValue("3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun") | |
7 | 7 | ||
8 | 8 | let WAVELET = ((100 * 1000) * 1000) | |
9 | 9 | ||
10 | 10 | let COMMISSION = ((5 * WAVELET) / 1000) | |
11 | 11 | ||
12 | 12 | let TicketsPerWave = 100 | |
13 | 13 | ||
14 | 14 | let CURRENTGAME = "$CURRENT_GAME" | |
15 | 15 | ||
16 | 16 | let LASTTICKET = "$LAST_TICKET" | |
17 | - | ||
18 | - | let BANK = "$GAME_BANK" | |
19 | 17 | ||
20 | 18 | func GenerateRandInt (gameId,rsaSign) = { | |
21 | 19 | let lastTicket = getIntegerValue(BetServer, LASTTICKET) | |
22 | 20 | let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey) | |
23 | 21 | if (rsaSigValid) | |
24 | 22 | then { | |
25 | 23 | let rand = (toInt(sha256(rsaSign)) % lastTicket) | |
26 | 24 | if ((0 > rand)) | |
27 | 25 | then ((-1 * rand) + 1) | |
28 | 26 | else (rand + 1) | |
29 | 27 | } | |
30 | 28 | else throw("Invalid RSA signature") | |
31 | 29 | } | |
32 | 30 | ||
33 | 31 | ||
34 | 32 | func isWinner (ticketsStr,winTicket) = { | |
35 | 33 | let tickets = split(ticketsStr, "_") | |
36 | 34 | if (if ((winTicket >= parseIntValue(tickets[0]))) | |
37 | 35 | then (parseIntValue(tickets[1]) >= winTicket) | |
38 | 36 | else false) | |
39 | 37 | then true | |
40 | 38 | else if (if ((winTicket >= parseIntValue(tickets[2]))) | |
41 | 39 | then (parseIntValue(tickets[3]) >= winTicket) | |
42 | 40 | else false) | |
43 | 41 | then true | |
44 | 42 | else if (if ((winTicket >= parseIntValue(tickets[4]))) | |
45 | 43 | then (parseIntValue(tickets[5]) >= winTicket) | |
46 | 44 | else false) | |
47 | 45 | then true | |
48 | 46 | else if (if ((winTicket >= parseIntValue(tickets[6]))) | |
49 | 47 | then (parseIntValue(tickets[7]) >= winTicket) | |
50 | 48 | else false) | |
51 | 49 | then true | |
52 | 50 | else false | |
53 | 51 | } | |
54 | 52 | ||
55 | 53 | ||
56 | 54 | func win (gameId,winTicket,winnerAddressStr,bankBalance,totalWinnerBetsAmt) = { | |
57 | 55 | let winAmt = (((bankBalance - totalWinnerBetsAmt) * 90) / 100) | |
58 | 56 | let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)] | |
59 | 57 | let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)] | |
60 | 58 | ScriptResult(WriteSet(gameResult), TransferSet(winTX)) | |
61 | 59 | } | |
62 | 60 | ||
63 | 61 | ||
64 | 62 | @Callable(i) | |
65 | 63 | func generateResult (gameId,rsaSignCrypted) = { | |
66 | 64 | let currentGame = getStringValue(BetServer, CURRENTGAME) | |
67 | 65 | if ((currentGame == gameId)) | |
68 | 66 | then { | |
69 | 67 | let rsaSign = fromBase58String(rsaSignCrypted) | |
70 | 68 | let winTicket = GenerateRandInt(gameId, rsaSign) | |
71 | 69 | let players = getStringValue(BetServer, (gameId + "_players")) | |
72 | 70 | let playersList = split(players, "_") | |
73 | - | let bankBalance = getIntegerValue(BetServer, BANK) | |
71 | + | let bankBalance = getIntegerValue(BetServer, (gameId + "_$GAME_BANK")) | |
74 | 72 | if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[0]) + "_tickets")), winTicket)) | |
75 | 73 | then win(gameId, winTicket, playersList[0], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[0]) + "_totalBetsAmt"))) | |
76 | 74 | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[1]) + "_tickets")), winTicket)) | |
77 | 75 | then win(gameId, winTicket, playersList[1], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[1]) + "_totalBetsAmt"))) | |
78 | 76 | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[2]) + "_tickets")), winTicket)) | |
79 | 77 | then win(gameId, winTicket, playersList[2], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[2]) + "_totalBetsAmt"))) | |
80 | 78 | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[3]) + "_tickets")), winTicket)) | |
81 | 79 | then win(gameId, winTicket, playersList[3], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[3]) + "_totalBetsAmt"))) | |
82 | 80 | else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[4]) + "_tickets")), winTicket)) | |
83 | 81 | then win(gameId, winTicket, playersList[4], bankBalance, getIntegerValue(BetServer, (((gameId + "_") + playersList[4]) + "_totalBetsAmt"))) | |
84 | 82 | else throw("Error") | |
85 | 83 | } | |
86 | 84 | else throw(((("Current Game is " + currentGame) + ", but not ") + gameId)) | |
87 | 85 | } | |
88 | 86 | ||
89 | 87 |
github/deemru/w8io/169f3d6 33.57 ms ◑