tx · 5tEKP6aVwiDYZSB1sW2Zrrn2cjuUeEa1W1bxU51MuT2W

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.09.07 01:59 [664842] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "5tEKP6aVwiDYZSB1sW2Zrrn2cjuUeEa1W1bxU51MuT2W", "fee": 1400000, "feeAssetId": null, "timestamp": 1567809845065, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "37uhkk8cvuMDaQk6umVPnZRRiM8JZMEU73PgdEiY54gmDa16tJS7QFPJ4cEZwfRsoU9rcJuPgiZNE3htdRb4Grdn" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA9TZXJ2ZXJQdWJsaWNLZXkJAAJZAAAAAQIAAAAsN2ltOWNhaUNtRTRTTDZqVG00S1RpY0hINGJHUGY1djU5cm5mVUEzY0NSRGoAAAAAElNlcnZlckJldFB1YmxpY0tleQkAAlkAAAABAgAAACw3aW05Y2FpQ21FNFNMNmpUbTRLVGljSEg0YkdQZjV2NTlybmZVQTNjQ1JEagAAAAAHV0FWRUxFVAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAA+gAAAAAAAAAA+gAAAAACkNPTU1JU1NJT04JAABpAAAAAgkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAAAAAPoAQAAAA9HZW5lcmF0ZVJhbmRJbnQAAAADAAAABmdhbWVJZAAAAAdyc2FTaWduAAAACmxhc3RUaWNrZXQEAAAAC3JzYVNpZ1ZhbGlkCQAB9AAAAAMJAAGbAAAAAQUAAAAGZ2FtZUlkBQAAAAdyc2FTaWduBQAAAA9TZXJ2ZXJQdWJsaWNLZXkDBQAAAAtyc2FTaW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W50c0xpc3QFAAAACXdpbm5lck51bQUAAAAEdW5pdAUAAAADbmlsBAAAAApnYW1lUmVzdWx0CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAABmdhbWVJZAIAAAAHX3Jlc3VsdAkAAaQAAAABBQAAAAl3aW5UaWNrZXQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAdfd2lubmVyCQABkQAAAAIFAAAAC3BsYXllcnNMaXN0BQAAAAl3aW5uZXJOdW0JAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAdfd2luQW10CQABkQAAAAIFAAAADndpbkFtb3VudHNMaXN0BQAAAAl3aW5uZXJOdW0FAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEFAAAACmdhbWVSZXN1bHQJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAABXdpblRYAAAAAIOrGsA=", "chainId": 84, "height": 664842, "spentComplexity": 0 } View: original | compacted Prev: 6MjK6a8hGxdYsfthntDygKdDQHemsf7ZmNC7B3zz26xs Next: DuKUZisMxrbKqG5HgJ8c8Up3NNwkATXhM6zwGMtQb5UZ Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
55
66 let ServerBetPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
77
88 let WAVELET = ((100 * 1000) * 1000)
99
1010 let COMMISSION = ((5 * WAVELET) / 1000)
1111
1212 func GenerateRandInt (gameId,rsaSign,lastTicket) = {
1313 let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey)
1414 if (rsaSigValid)
1515 then {
1616 let rand = (toInt(sha256(rsaSign)) % lastTicket)
1717 if ((0 > rand))
1818 then ((-1 * rand) + 1)
1919 else (rand + 1)
2020 }
2121 else throw("Invalid RSA signature")
2222 }
2323
2424
2525 func getPlayersTickets (gameId,player) = {
2626 let ticketsStr = (((gameId + "_") + player) + "_tickets")
2727 let playerTicketsStr = getStringValue(this, ticketsStr)
2828 playerTicketsStr
2929 }
3030
3131
3232 func ParseNextAttribute (remaining) = {
3333 let s = size(remaining)
3434 if ((s > 0))
3535 then {
3636 let nn = parseIntValue(take(remaining, 2))
3737 let v = take(drop(remaining, 2), nn)
3838 let tmpRemaining = drop(remaining, (nn + 2))
3939 let remainingState = tmpRemaining
4040 [v, remainingState]
4141 }
4242 else throw("Empty string was passed into parseNextAttribute func")
4343 }
4444
4545
4646 func parseBetStr (ticketsStr) = ["1", "100", "101", "300", "0", "0", "0", "0"]
4747
4848
4949 func isWinner (gameId,player,winTicket) = {
5050 let playersTicket = getPlayersTickets(gameId, player)
5151 let bets = parseBetStr(playersTicket)
5252 if (if ((winTicket >= parseIntValue(bets[0])))
5353 then (parseIntValue(bets[1]) >= winTicket)
5454 else false)
5555 then true
5656 else if (if ((winTicket >= parseIntValue(bets[2])))
5757 then (parseIntValue(bets[3]) >= winTicket)
5858 else false)
5959 then true
6060 else if (if ((winTicket >= parseIntValue(bets[4])))
6161 then (parseIntValue(bets[5]) >= winTicket)
6262 else false)
6363 then true
6464 else if (if ((winTicket >= parseIntValue(bets[6])))
6565 then (parseIntValue(bets[7]) >= winTicket)
6666 else false)
6767 then true
6868 else false
6969 }
7070
7171
7272 func defineWinner (gameId,players,winAmounts,winTicket) = {
7373 let playersList = split(players, "_")
7474 let winAmountsList = split(winAmounts, "_")
7575 if (isWinner(gameId, playersList[0], winTicket))
7676 then 0
7777 else if (isWinner(gameId, playersList[1], winTicket))
7878 then 1
7979 else if (isWinner(gameId, playersList[2], winTicket))
8080 then 2
8181 else if (isWinner(gameId, playersList[3], winTicket))
8282 then 3
8383 else if (isWinner(gameId, playersList[4], winTicket))
8484 then 4
8585 else if (isWinner(gameId, playersList[5], winTicket))
8686 then 5
8787 else throw("Error with defining winner")
8888 }
8989
9090
9191 @Callable(i)
9292 func bet (gameId,gameIdCryptedStr,tickets) = {
9393 let gameIdCrypted = fromBase58String(gameIdCryptedStr)
9494 let pmt = extract(i.payment)
9595 let betNotInWaves = isDefined(pmt.assetId)
9696 let feeNotInWaves = isDefined(pmt.assetId)
9797 let playerPubKey58 = toBase58String(i.callerPublicKey)
9898 let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
9999 let gameStillOpen = isDefined(getString(this, (gameId + "_result")))
100100 if (!(gameStillOpen))
101101 then if (betNotInWaves)
102102 then throw("Bet amount must be in Waves")
103103 else if (feeNotInWaves)
104104 then throw("Transaction's fee must be in Waves")
105105 else {
106106 let rsaSigValid = sigVerify(toBytes(gameId), gameIdCrypted, ServerBetPublicKey)
107107 if (rsaSigValid)
108108 then {
109109 let playerAddressStr = toString(playerAddress)
110110 let betData = [DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), tickets)]
111111 WriteSet(betData)
112112 }
113113 else throw("Invalid RSA signature")
114114 }
115115 else throw("This game already end, try make bet again")
116116 }
117117
118118
119119
120120 @Callable(i)
121121 func generateResult (gameId,rsaSignCrypted,lastTicket,players,winAmounts) = {
122122 let rsaSign = fromBase58String(rsaSignCrypted)
123123 let winTicket = GenerateRandInt(gameId, rsaSign, lastTicket)
124124 let playersList = split(players, "_")
125125 let winAmountsList = split(winAmounts, "_")
126126 let winnerNum = defineWinner(gameId, players, winAmounts, winTicket)
127127 let winTX = [ScriptTransfer(addressFromStringValue(playersList[winnerNum]), parseIntValue(winAmountsList[winnerNum]), unit)]
128128 let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), playersList[winnerNum]), DataEntry((gameId + "_winAmt"), winAmountsList[winnerNum])]
129129 ScriptResult(WriteSet(gameResult), TransferSet(winTX))
130130 }
131131
132132

github/deemru/w8io/026f985 
40.09 ms