tx · FZaVVwuudjyPinYPnh2twVyVoL6EezfDWF72xkYXN69a

3MsGBnTzBhrNe6w1KpLYPkzdDdxWudm4U89:  -0.01400000 Waves

2019.08.21 09:43 [640535] smart account 3MsGBnTzBhrNe6w1KpLYPkzdDdxWudm4U89 > SELF 0.00000000 Waves

{ "type": 13, "id": "FZaVVwuudjyPinYPnh2twVyVoL6EezfDWF72xkYXN69a", "fee": 1400000, "feeAssetId": null, "timestamp": 1566369779177, "version": 1, "sender": "3MsGBnTzBhrNe6w1KpLYPkzdDdxWudm4U89", "senderPublicKey": "FgbqvGasMMrXxbhwrsgEiCgJLjXPjgn8kHxsZiVmLrkb", "proofs": [ "46MnVQEFEfwPwwN4SnzZ65viTxy2NRVJFdjvmVgUoCZWNP7iTnAVhJCVfMuPcQv1jk9baTcxwVgSi1UrMLhY4V2o" ], "script": "base64:AAIDAAAAAAAAAAAAAAAgAAAAAAlSU0FQVUJMSUMJAAJbAAAAAQIAAAGPYmFzZTY0Ok1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBbGVtcjk1SjFqWlVzN2NKbXJtbWxONHpvN1lWc0JKekllSmRrOExERkdoVUtTSTZ5ZnMyMFp5SmUyMSs2R0p3Tm5LVVUxVXlvYzE3d1NXTUtrclowTU12WUUrWjVBaWlqdkJLNHNTSjNJZ0dqZFU4L05oSThDQkR1MEYreFJNOXEzVEIzTExiRHk1c0JkdWRZZkhmc1VPYytNVHZBRDY5bjI3ZGIyUmg4K3laUU10dWJrdVRRTnA4OXNwaEhRYUxHeVFGYU5sSy9OYTNsRng2b21xemFhMWdqb3BsVXI2cnZZS2dmQUlDVUIzelZtSlNoaUVpN3c3UjBoV2xOUkQzcWNaakNVT05TcEZvNFdiemtuR09henc4NEIrSU1JRm5JcFhXelFMOFJYMHZOY2ZzQnZMRGZNNmsyWmFjcXd5TUthTExxaWdkQmlHZEo3VyswbE9TdE9RSURBUUFCAAAAABNSQU5ET1JBQ0xFV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ZWlnaHQFAAAABndpbkFtdAIAAAAABAAAAAZTRVJWRVIJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQQAAAAOc2VydmVyVHJhbnNmZXIJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAGU0VSVkVSBQAAAApDT01NSVNTSU9OBQAAAAR1bml0BQAAAANuaWwEAAAAB2JldERhdGEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAADlJFU0VSVkFUSU9OS0VZCQEAAAAeVmFsaWRhdGVBbmRJbmNyZWFzZVJlc2VydmVkQW10AAAAAQUAAAAGd2luQW10CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAA9HQU1FU0NPVU5URVJLRVkFAAAACm5ld0dhbWVOdW0JAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAABmdhbWVJZAUAAAALZ2FtZURhdGFTdHIFAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEFAAAAB2JldERhdGEJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAADnNlcnZlclRyYW5zZmVyAAAAAGr4Mxw=", "chainId": 84, "height": 640535, "spentComplexity": 0 } View: original | compacted Prev: SdbTsCAiPk8fsrHpmZBw4vnWT7PuWxbpYu8kK1Ysxim Next: 9fSDAxX9uypZWBcdkeJiMqx9H49oNpTh6qKtpk91ZN3F Diff:
OldNewDifferences
77
88 let WAVELET = ((100 * 1000) * 1000)
99
10-let COMMISSION = ((5 * WAVELET) / 1000)
10+let COMMISSION = ((9 * WAVELET) / 1000)
1111
1212 let BET1 = (1 * WAVELET)
1313
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlemr95J1jZUs7cJmrmmlN4zo7YVsBJzIeJdk8LDFGhUKSI6yfs20ZyJe21+6GJwNnKUU1Uyoc17wSWMKkrZ0MMvYE+Z5AiijvBK4sSJ3IgGjdU8/NhI8CBDu0F+xRM9q3TB3LLbDy5sBdudYfHfsUOc+MTvAD69n27db2Rh8+yZQMtubkuTQNp89sphHQaLGyQFaNlK/Na3lFx6omqzaa1gjoplUr6rvYKgfAICUB3zVmJShiEi7w7R0hWlNRD3qcZjCUONSpFo4WbzknGOazw84B+IMIFnIpXWzQL8RX0vNcfsBvLDfM6k2ZacqwyMKaLLqigdBiGdJ7W+0lOStOQIDAQAB")
55
66 let RANDORACLETIMEFRAME = 4320
77
88 let WAVELET = ((100 * 1000) * 1000)
99
10-let COMMISSION = ((5 * WAVELET) / 1000)
10+let COMMISSION = ((9 * WAVELET) / 1000)
1111
1212 let BET1 = (1 * WAVELET)
1313
1414 let BET2 = (2 * WAVELET)
1515
1616 let BET4 = (4 * WAVELET)
1717
1818 let BET8 = (8 * WAVELET)
1919
2020 let BET14 = (14 * WAVELET)
2121
2222 let RATEMULT = 10000
2323
2424 let RATE1 = 39655
2525
2626 let RATE2 = 24600
2727
2828 let RATE3 = 19000
2929
3030 let RATE4 = 14200
3131
3232 let RATE5 = 11400
3333
3434 let GAMESCOUNTERKEY = "$GAME_NUM"
3535
3636 let RESERVATIONKEY = "$RESERVED_AMOUNT"
3737
3838 let STATESUBMITTED = "SUBMITTED"
3939
4040 let STATEWON = "WON"
4141
4242 let STATELOST = "LOST"
4343
4444 func getAnswer (playerChoice) = BET14
4545
4646
4747 func GenerateRandInt (gameId,rsaSign) = {
4848 let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC)
4949 if (rsaSigValid)
5050 then {
5151 let rand = (toInt(sha256(rsaSign)) % 6)
5252 if ((0 > rand))
5353 then (-1 * rand)
5454 else rand
5555 }
5656 else throw("Invalid RSA signature")
5757 }
5858
5959
6060 func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0))
6161 then drop(remaining, 1)
6262 else remaining
6363
6464
6565 func ParseNextAttribute (remaining) = {
6666 let s = size(remaining)
6767 if ((s > 0))
6868 then {
6969 let nn = parseIntValue(take(remaining, 2))
7070 let v = take(drop(remaining, 2), nn)
7171 let tmpRemaining = drop(remaining, (nn + 2))
7272 let remainingState = RemoveUnderscoreIfPresent(tmpRemaining)
7373 [v, remainingState]
7474 }
7575 else throw("Empty string was passed into parseNextAttribute func")
7676 }
7777
7878
7979 func ParseGameRawDataStr (rawStateStr) = {
8080 let gameState = ParseNextAttribute(rawStateStr)
8181 let playerChoice = ParseNextAttribute(gameState[1])
8282 let playerPubKey58 = ParseNextAttribute(playerChoice[1])
8383 let startedHeight = ParseNextAttribute(playerPubKey58[1])
8484 let winAmt = ParseNextAttribute(startedHeight[1])
8585 [gameState[0], playerChoice[0], playerPubKey58[0], startedHeight[0], winAmt[0]]
8686 }
8787
8888
8989 func ExtractGameDataList (gameId) = {
9090 let rawDataStr = match getString(this, gameId) {
9191 case str: String =>
9292 str
9393 case _ =>
9494 throw(("Couldn't find game by " + gameId))
9595 }
9696 ParseGameRawDataStr(rawDataStr)
9797 }
9898
9999
100100 func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) {
101101 case a: Int =>
102102 a
103103 case _ =>
104104 0
105105 }
106106
107107
108108 func ValidateAndIncreaseReservedAmt (winAmt) = {
109109 let newReservedAmount = (ExtractReservedAmt() + winAmt)
110110 let balance = wavesBalance(this)
111111 if ((newReservedAmount > balance))
112112 then throw("Insufficient funds on Russian Roulette account. Transaction was rejected for your safety.")
113113 else newReservedAmount
114114 }
115115
116116
117117 func IncrementGameNum () = {
118118 let gameNum = match getInteger(this, GAMESCOUNTERKEY) {
119119 case num: Int =>
120120 num
121121 case _ =>
122122 0
123123 }
124124 (gameNum + 1)
125125 }
126126
127127
128128 func FormatGameDataParam (p) = {
129129 let s = size(p)
130130 if ((s == 0))
131131 then throw("Parameter size must be greater then 0")
132132 else if ((s > 99))
133133 then throw("Parameter size must be less then 100")
134134 else if ((10 > s))
135135 then (("0" + toString(s)) + p)
136136 else (toString(s) + p)
137137 }
138138
139139
140140 func FormatGameDataStr (gameState,playerChoice,playerPubKey58,startedHeight,winAmt,randOrEmpty) = {
141141 let fullStateStr = ((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(playerChoice)) + "_") + FormatGameDataParam(playerPubKey58)) + "_") + FormatGameDataParam(toString(startedHeight))) + "_") + FormatGameDataParam(toString(winAmt)))
142142 if ((randOrEmpty == ""))
143143 then fullStateStr
144144 else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty))
145145 }
146146
147147
148148 func ValidateBetAndDefineWinAmt (betAmt,playerChoice) = {
149149 let betAmtValid = if (if (if (if (if ((betAmt == (BET1 + COMMISSION)))
150150 then true
151151 else (betAmt == (BET2 + COMMISSION)))
152152 then true
153153 else (betAmt == (BET4 + COMMISSION)))
154154 then true
155155 else (betAmt == (BET8 + COMMISSION)))
156156 then true
157157 else (betAmt == (BET14 + COMMISSION)))
158158 then true
159159 else false
160160 if (betAmtValid)
161161 then {
162162 let bulletsCount = size(playerChoice)
163163 let bet = (betAmt - COMMISSION)
164164 if ((bulletsCount == 5))
165165 then ((bet * RATE1) / RATEMULT)
166166 else if ((bulletsCount == 4))
167167 then ((bet * RATE2) / RATEMULT)
168168 else if ((bulletsCount == 3))
169169 then ((bet * RATE3) / RATEMULT)
170170 else if ((bulletsCount == 2))
171171 then ((bet * RATE4) / RATEMULT)
172172 else if ((bulletsCount == 1))
173173 then ((bet * RATE5) / RATEMULT)
174174 else throw("Invalid bullets in player's choice")
175175 }
176176 else throw("Bet amount is not in range")
177177 }
178178
179179
180180 @Callable(i)
181181 func bet (playerChoice) = {
182182 let newGameNum = IncrementGameNum()
183183 let gameId = toBase58String(i.transactionId)
184184 let pmt = extract(i.payment)
185185 let betNotInWaves = isDefined(pmt.assetId)
186186 let feeNotInWaves = isDefined(pmt.assetId)
187187 let winAmt = ValidateBetAndDefineWinAmt(pmt.amount, playerChoice)
188188 let txIdUsed = isDefined(getString(this, gameId))
189189 if (betNotInWaves)
190190 then throw("Bet amount must be in Waves")
191191 else if (feeNotInWaves)
192192 then throw("Transaction's fee must be in Waves")
193193 else if (txIdUsed)
194194 then throw("Passed txId had been used before. Game aborted.")
195195 else {
196196 let playerPubKey58 = toBase58String(i.callerPublicKey)
197197 let gameDataStr = FormatGameDataStr(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmt, "")
198198 let SERVER = addressFromPublicKey(i.callerPublicKey)
199199 let serverTransfer = [ScriptTransfer(SERVER, COMMISSION, unit)]
200200 let betData = [DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]
201201 ScriptResult(WriteSet(betData), TransferSet(serverTransfer))
202202 }
203203 }
204204
205205

github/deemru/w8io/026f985 
31.86 ms