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