tx · 27VSNnKyqfrNh4wCV1WFYtNqzJmPVGMxgG6S87qCmpr5

3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE:  -0.01500000 Waves

2019.07.17 15:58 [589877] smart account 3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE > SELF 0.00000000 Waves

{ "type": 13, "id": "27VSNnKyqfrNh4wCV1WFYtNqzJmPVGMxgG6S87qCmpr5", "fee": 1500000, "feeAssetId": null, "timestamp": 1563368326070, "version": 1, "sender": "3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE", "senderPublicKey": "8fdATo5z3B5EweA3kKoRgbJZhGa4JicyHHMkhBZTvNSf", "proofs": [ "8SDRFuhhtoB2QRwfaDknjxQcVD9cuJaDLizTUCyZuUQcBCNr4QvPH9pjZ6jgmyvQVttczfjRYm2WzgT3UgyMpvh" ], "script": "base64:AAIDAAAAAAAAAAAAAAARAAAAAAlXYXZlc011bHQAAAAAAAX14QAAAAAABGJldDEJAABoAAAAAgAAAAAAAAAAAQUAAAAJV2F2ZXNNdWx0AAAAAARiZXQ1CQAAaAAAAAIAAAAAAAAAAAUFAAAACVdhdmVzTXVsdAAAAAAFYmV0MTUJAABoAAAAAgAAAAAAAAAADwUAAAAJV2F2ZXNNdWx0AAAAAAViZXQ0MAkAAGgAAAACAAAAAAAAAAAoBQAAAAlXYXZlc011bHQAAAAABmJldDEwMAkAAGgAAAACAAAAAAAAAABkBQAAAAlXYXZlc011bHQAAAAACWNvbWlzc2lvbgAAAAAAAExLQAAAAAAPb3JhY2xlUHVibGljS2V5CQACWwAAAAECAAAAh2Jhc2U2NDpNRnd3RFFZSktvWklodmNOQVFFQkJRQURTd0F3U0FKQkFNWnVMb0xIVjVmY3VxUC9LakhvUTZWc1pTa1NXRjJBd1JBTHJMZ1RVZlhZc2RKdzF6djB0OXY3SUhSNjNnN1lyb0N2VUZTWG0xUm1PaFMxWGpyNXlJRUNBd0VBQVE9PQAAAAANZGFwcFB1YmxpY0tleQEAAAABAAAAAAANZ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AAAAAWEAAAAAAAAAAAAEAAAAEGF2YWlsYWJsZUJhbGFuY2UJAABlAAAAAgkBAAAADHdhdmVzQmFsYW5jZQAAAAEFAAAABHRoaXMFAAAAD3Jlc2VydmVkQmFsYW5jZQQAAAAPYXZhaWxpYmxlQW1vdW50CQAAZwAAAAIFAAAAEGF2YWlsYWJsZUJhbGFuY2UIBQAAAAN0dHgAAAAGYW1vdW50BAAAAAlzaWduYXR1cmUJAAH0AAAAAwgFAAAAA3R0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAA3R0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADWRhcHBQdWJsaWNLZXkDBQAAAA9hdmFpbGlibGVBbW91bnQFAAAACXNpZ25hdHVyZQcDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAARzc3R4BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAARzc3R4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAAEc3N0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADWRhcHBQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAARpc3R4BQAAAAckbWF0Y2gwBgdt3frC", "chainId": 84, "height": 589877, "spentComplexity": 0 } View: original | compacted Prev: A1ck512fybHMZivTSc3Jj7dqSnekfMcVsQkHubqCM1Yj Next: none Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let Waves = 100000000
4+let WavesMult = 100000000
55
6-let bet1 = (1 * Waves)
6+let bet1 = (1 * WavesMult)
77
8-let bet5 = (5 * Waves)
8+let bet5 = (5 * WavesMult)
99
10-let bet10 = (10 * Waves)
10+let bet15 = (15 * WavesMult)
1111
12-let bet25 = (25 * Waves)
12+let bet40 = (40 * WavesMult)
1313
14-let bet100 = (100 * Waves)
14+let bet100 = (100 * WavesMult)
1515
1616 let comission = 5000000
1717
1818 let oraclePublicKey = fromBase64String("base64:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMZuLoLHV5fcuqP/KjHoQ6VsZSkSWF2AwRALrLgTUfXYsdJw1zv0t9v7IHR63g7YroCvUFSXm1RmOhS1Xjr5yIECAwEAAQ==")
19+
20+let dappPublicKey = base58'1'
1921
2022 let gameTimeFrame = 1440
2123
2729
2830 let stateLose = "Lose"
2931
32+let timeountNum = "WithoutNum"
33+
34+func writeSet (gameId,stringForNewData,rsaToString,state,newReservedBalance) = WriteSet([DataEntry(gameId, ((((state + "_") + stringForNewData) + "_") + rsaToString)), DataEntry("Reserved", newReservedBalance)])
35+
36+
37+func transferSet (address,prize) = TransferSet([ScriptTransfer(address, prize, unit)])
38+
39+
3040 @Callable(i)
3141 func bet (choice) = {
3242 let pmnt = extract(i.payment)
3343 let gameId = toBase58String(i.transactionId)
3444 let gameStart = height
35- let gameCounter = {
36- let gameNumber = {
37- let counterValue = getInteger(this, "GamesCounter")
38- match counterValue {
39- case p: Int =>
40- p
41- case _ =>
42- 0
43- }
44- }
45- (gameNumber + 1)
46- }
4745 let betAssetIdCheck = isDefined(pmnt.assetId)
4846 let playerPublicKey = toBase58String(i.callerPublicKey)
4947 let playerChoice = if (if ((choice == "1"))
5755 then true
5856 else (bet == bet5))
5957 then true
60- else (bet == bet10))
58+ else (bet == bet15))
6159 then true
62- else (bet == bet25))
60+ else (bet == bet40))
6361 then true
6462 else (bet == bet100))
6563 then (bet * 2)
111109 addressFromPublicKey(fromBase58String(a))
112110 }
113111 let playerChoice = dataList[2]
112+ let playerPrize = {
113+ let a = dataList[3]
114+ parseIntValue(a)
115+ }
116+ let gameStart = {
117+ let a = dataList[4]
118+ parseIntValue(a)
119+ }
114120 let rsaToInt = {
115121 let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, oraclePublicKey)
116122 if (rsaCheck)
123129 else throw("Rsa integer is not in range")
124130 }
125131 else throw("Rsa Signature is invalid")
126- }
127- let gameStart = {
128- let a = dataList[4]
129- parseIntValue(a)
130- }
131- let playerPrize = {
132- let a = dataList[3]
133- parseIntValue(a)
134132 }
135133 let newReservedBalance = {
136134 let valueReservedBalance = getInteger(this, "Reserved")
146144 else throw("Reserved balance couldn't be less than 0")
147145 }
148146 let stringForNewData = ((((((dataList[1] + "_") + dataList[2]) + "_") + dataList[3]) + "_") + dataList[4])
147+ let rsaString = toString(rsaToInt)
149148 let gameTime = (gameTimeFrame > (height - gameStart))
150149 let stateCheck = (gameState == stateAcc)
151150 if (stateCheck)
160159 (rsaToState == playerChoice)
161160 }
162161 if (playerWin)
163- then ScriptResult(WriteSet([DataEntry(gameId, ((((stateWin + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)]))
164- else WriteSet([DataEntry(gameId, ((((stateLose + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)])
162+ then ScriptResult(writeSet(gameId, stringForNewData, rsaString, stateWin, newReservedBalance), transferSet(playerAddress, playerPrize))
163+ else writeSet(gameId, stringForNewData, rsaString, stateLose, newReservedBalance)
165164 }
166165 else throw("Game state is invalid")
167- else ScriptResult(WriteSet([DataEntry(gameId, ((((stateTimeout + "_") + stringForNewData) + "_") + "00")), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)]))
166+ else ScriptResult(writeSet(gameId, stringForNewData, timeountNum, stateTimeout, newReservedBalance), transferSet(playerAddress, playerPrize))
168167 }
169168
170169
180179 }
181180 let availableBalance = (wavesBalance(this) - reservedBalance)
182181 let availibleAmount = (availableBalance >= ttx.amount)
183- let signature = sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey)
182+ let signature = sigVerify(ttx.bodyBytes, ttx.proofs[0], dappPublicKey)
184183 if (availibleAmount)
185184 then signature
186185 else false
187186 case sstx: SetScriptTransaction =>
188- sigVerify(sstx.bodyBytes, sstx.proofs[0], sstx.senderPublicKey)
187+ sigVerify(sstx.bodyBytes, sstx.proofs[0], dappPublicKey)
189188 case istx: InvokeScriptTransaction =>
190189 true
191190 case _ =>
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let Waves = 100000000
4+let WavesMult = 100000000
55
6-let bet1 = (1 * Waves)
6+let bet1 = (1 * WavesMult)
77
8-let bet5 = (5 * Waves)
8+let bet5 = (5 * WavesMult)
99
10-let bet10 = (10 * Waves)
10+let bet15 = (15 * WavesMult)
1111
12-let bet25 = (25 * Waves)
12+let bet40 = (40 * WavesMult)
1313
14-let bet100 = (100 * Waves)
14+let bet100 = (100 * WavesMult)
1515
1616 let comission = 5000000
1717
1818 let oraclePublicKey = fromBase64String("base64:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMZuLoLHV5fcuqP/KjHoQ6VsZSkSWF2AwRALrLgTUfXYsdJw1zv0t9v7IHR63g7YroCvUFSXm1RmOhS1Xjr5yIECAwEAAQ==")
19+
20+let dappPublicKey = base58'1'
1921
2022 let gameTimeFrame = 1440
2123
2224 let stateAcc = "Accepted"
2325
2426 let stateWin = "Win"
2527
2628 let stateTimeout = "WinByTimeout"
2729
2830 let stateLose = "Lose"
2931
32+let timeountNum = "WithoutNum"
33+
34+func writeSet (gameId,stringForNewData,rsaToString,state,newReservedBalance) = WriteSet([DataEntry(gameId, ((((state + "_") + stringForNewData) + "_") + rsaToString)), DataEntry("Reserved", newReservedBalance)])
35+
36+
37+func transferSet (address,prize) = TransferSet([ScriptTransfer(address, prize, unit)])
38+
39+
3040 @Callable(i)
3141 func bet (choice) = {
3242 let pmnt = extract(i.payment)
3343 let gameId = toBase58String(i.transactionId)
3444 let gameStart = height
35- let gameCounter = {
36- let gameNumber = {
37- let counterValue = getInteger(this, "GamesCounter")
38- match counterValue {
39- case p: Int =>
40- p
41- case _ =>
42- 0
43- }
44- }
45- (gameNumber + 1)
46- }
4745 let betAssetIdCheck = isDefined(pmnt.assetId)
4846 let playerPublicKey = toBase58String(i.callerPublicKey)
4947 let playerChoice = if (if ((choice == "1"))
5048 then true
5149 else (choice == "2"))
5250 then choice
5351 else throw("Player's choice is incorrect")
5452 let playerPrize = {
5553 let bet = (pmnt.amount - comission)
5654 if (if (if (if (if ((bet == bet1))
5755 then true
5856 else (bet == bet5))
5957 then true
60- else (bet == bet10))
58+ else (bet == bet15))
6159 then true
62- else (bet == bet25))
60+ else (bet == bet40))
6361 then true
6462 else (bet == bet100))
6563 then (bet * 2)
6664 else throw("Payment amount is incorrect")
6765 }
6866 let reservedBalance = {
6967 let currentReservedBalance = {
7068 let valueReservedBalance = getInteger(this, "Reserved")
7169 match valueReservedBalance {
7270 case a: Int =>
7371 a
7472 case _ =>
7573 0
7674 }
7775 }
7876 let newReservedBalance = (currentReservedBalance + playerPrize)
7977 if ((wavesBalance(this) >= newReservedBalance))
8078 then {
8179 let increaseReservedBalance = newReservedBalance
8280 increaseReservedBalance
8381 }
8482 else throw("Bet was rejected. Insufficient funds on game account.")
8583 }
8684 if (betAssetIdCheck)
8785 then throw("You can make bet in Waves only")
8886 else {
8987 let dataString = ((((((((stateAcc + "_") + playerPublicKey) + "_") + playerChoice) + "_") + toString(playerPrize)) + "_") + toString(gameStart))
9088 WriteSet([DataEntry("Reserved", reservedBalance), DataEntry(gameId, dataString)])
9189 }
9290 }
9391
9492
9593
9694 @Callable(i)
9795 func withdraw (gameId,rsaSign) = {
9896 let dataList = {
9997 let getDataString = getString(this, gameId)
10098 let a = match getDataString {
10199 case a: String =>
102100 a
103101 case _ =>
104102 throw("GameId was not found")
105103 }
106104 split(a, "_")
107105 }
108106 let gameState = dataList[0]
109107 let playerAddress = {
110108 let a = dataList[1]
111109 addressFromPublicKey(fromBase58String(a))
112110 }
113111 let playerChoice = dataList[2]
112+ let playerPrize = {
113+ let a = dataList[3]
114+ parseIntValue(a)
115+ }
116+ let gameStart = {
117+ let a = dataList[4]
118+ parseIntValue(a)
119+ }
114120 let rsaToInt = {
115121 let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, oraclePublicKey)
116122 if (rsaCheck)
117123 then {
118124 let rsaInt = ((toInt(sha256(rsaSign)) % 99) + 1)
119125 if (if ((rsaInt > 0))
120126 then (100 >= rsaInt)
121127 else false)
122128 then rsaInt
123129 else throw("Rsa integer is not in range")
124130 }
125131 else throw("Rsa Signature is invalid")
126- }
127- let gameStart = {
128- let a = dataList[4]
129- parseIntValue(a)
130- }
131- let playerPrize = {
132- let a = dataList[3]
133- parseIntValue(a)
134132 }
135133 let newReservedBalance = {
136134 let valueReservedBalance = getInteger(this, "Reserved")
137135 let extractReservedBalance = match valueReservedBalance {
138136 case a: Int =>
139137 a
140138 case _ =>
141139 0
142140 }
143141 let decreaseReservedBalance = (extractReservedBalance - playerPrize)
144142 if ((decreaseReservedBalance > 0))
145143 then decreaseReservedBalance
146144 else throw("Reserved balance couldn't be less than 0")
147145 }
148146 let stringForNewData = ((((((dataList[1] + "_") + dataList[2]) + "_") + dataList[3]) + "_") + dataList[4])
147+ let rsaString = toString(rsaToInt)
149148 let gameTime = (gameTimeFrame > (height - gameStart))
150149 let stateCheck = (gameState == stateAcc)
151150 if (stateCheck)
152151 then if (gameTime)
153152 then {
154153 let playerWin = {
155154 let rsaToState = if ((48 > rsaToInt))
156155 then "1"
157156 else if ((rsaToInt > 52))
158157 then "2"
159158 else "3"
160159 (rsaToState == playerChoice)
161160 }
162161 if (playerWin)
163- then ScriptResult(WriteSet([DataEntry(gameId, ((((stateWin + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)]))
164- else WriteSet([DataEntry(gameId, ((((stateLose + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)])
162+ then ScriptResult(writeSet(gameId, stringForNewData, rsaString, stateWin, newReservedBalance), transferSet(playerAddress, playerPrize))
163+ else writeSet(gameId, stringForNewData, rsaString, stateLose, newReservedBalance)
165164 }
166165 else throw("Game state is invalid")
167- else ScriptResult(WriteSet([DataEntry(gameId, ((((stateTimeout + "_") + stringForNewData) + "_") + "00")), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)]))
166+ else ScriptResult(writeSet(gameId, stringForNewData, timeountNum, stateTimeout, newReservedBalance), transferSet(playerAddress, playerPrize))
168167 }
169168
170169
171170 @Verifier(tx)
172171 func verify () = match tx {
173172 case ttx: TransferTransaction =>
174173 let valueReservedBalance = getInteger(this, "Reserved")
175174 let reservedBalance = match valueReservedBalance {
176175 case a: Int =>
177176 a
178177 case _ =>
179178 0
180179 }
181180 let availableBalance = (wavesBalance(this) - reservedBalance)
182181 let availibleAmount = (availableBalance >= ttx.amount)
183- let signature = sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey)
182+ let signature = sigVerify(ttx.bodyBytes, ttx.proofs[0], dappPublicKey)
184183 if (availibleAmount)
185184 then signature
186185 else false
187186 case sstx: SetScriptTransaction =>
188- sigVerify(sstx.bodyBytes, sstx.proofs[0], sstx.senderPublicKey)
187+ sigVerify(sstx.bodyBytes, sstx.proofs[0], dappPublicKey)
189188 case istx: InvokeScriptTransaction =>
190189 true
191190 case _ =>
192191 false
193192 }
194193

github/deemru/w8io/169f3d6 
39.79 ms