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