tx · HUzMf3NUjPvhY22ybxDPha8gN1kbUcRs7zCH9ALunri4

3MtYk9gYGTZgSZwshc7ypE499hcCUnKsevx:  -0.01000000 Waves

2019.07.21 15:22 [595713] smart account 3MtYk9gYGTZgSZwshc7ypE499hcCUnKsevx > SELF 0.00000000 Waves

{ "type": 13, "id": "HUzMf3NUjPvhY22ybxDPha8gN1kbUcRs7zCH9ALunri4", "fee": 1000000, "feeAssetId": null, "timestamp": 1563711836198, "version": 1, "sender": "3MtYk9gYGTZgSZwshc7ypE499hcCUnKsevx", "senderPublicKey": "7YMR3NTVNBdVZAZnMF9tLgZbHXjTPykk3FarVrEE4mB2", "proofs": [ "eu4qWRBKnvdCNzXAeJi8nocXexodsxq75EWs1s2JYj5nvrKVnvPgYADNuJjt9jsf6Jj2WfhY6qeHtowTJxGuMRY" ], "script": "base64:AAIDAAAAAAAAAAAAAAAoAAAAAA9TZXJ2ZXJQdWJsaWNLZXkBAAAAIAsoHUeLtZkyzNPc+1+ktrvkEUCDQsYcz7NPlRQhjeYWAAAAAA1TZXJ2ZXJBZGRyZXNzCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNNdUptQ1NFVWdCTnkxUjJnZXNrNTl4RGJXY3VUS3d3aXhXAAAAABBSb3VsZXR0ZVNlY3Rpb25zAAAAAAAAAAAVAAAAABFEYXRhR2FtZU51bWJlcktleQIAAAALQVBQX0dBTUVfSUQAAAAAD0RhdGFVc2VyR2FtZUtleQIAAAANVVNFUl9HQU1FX0lEXwAAAAANRGF0YUFtb3VudEtleQIAAAAGQU1PVU5UAAAAAA5EYXRhU2VjdGlvbktleQIAAAAHU0VDVElPTgAAAAANRGF0YVN0YXR1c0tleQIAAAAGU1RBVFVTAAAAAA1EYXRhUmVzdWx0S2V5AgAAAAZSRVNVTFQAAAAAEERhdGFXaW5BbW91bnRLZXkCAAAACldJTl9BTU9VTlQAAAAADURhdGFTdGF0dXNOZXcCAAAAA05FVwAAA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aW9uSWQFAAAAEERhdGFXaW5BbW91bnRLZXkJAQAAAAxTY3JpcHRSZXN1bHQAAAACBQAAAAh3cml0ZVNldAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAEFAAAABndhbGxldAUAAAAJd2luQW1vdW50BQAAAAR1bml0BQAAAANuaWwFAAAACHdyaXRlU2V0CQAAAgAAAAEJAAEsAAAAAgUAAAANRXJyb3JHYW1lT3ZlcgUAAAAGc3RhdHVzAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAMJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAADdHR4BQAAAAckbWF0Y2gwBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAA3N0eAUAAAAHJG1hdGNoMAYHBxtC5z4=", "chainId": 84, "height": 595713, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let ServerPublicKey = base58'kYxoGdY4mv5zMYWYJTq3Pp3uLDuLphTYfT8epjYEJvy'
5+
6+let ServerAddress = addressFromStringValue("3MuJmCSEUgBNy1R2gesk59xDbWcuTKwwixW")
7+
8+let RouletteSections = 21
9+
10+let DataGameNumberKey = "APP_GAME_ID"
11+
12+let DataUserGameKey = "USER_GAME_ID_"
13+
14+let DataAmountKey = "AMOUNT"
15+
16+let DataSectionKey = "SECTION"
17+
18+let DataStatusKey = "STATUS"
19+
20+let DataResultKey = "RESULT"
21+
22+let DataWinAmountKey = "WIN_AMOUNT"
23+
24+let DataStatusNew = "NEW"
25+
26+let DataStatusWin = "WIN"
27+
28+let DataStatusLoose = "LOOSE"
29+
30+let WAVELET = ((100 * 1000) * 1000)
31+
32+let COMMISSION = ((5 * WAVELET) / 1000)
33+
34+let BET1 = (1 * WAVELET)
35+
36+let BET2 = (2 * WAVELET)
37+
38+let BET4 = (4 * WAVELET)
39+
40+let BET8 = (8 * WAVELET)
41+
42+let BET14 = (14 * WAVELET)
43+
44+let Sections = [0, 2, 20, 2, 5, 2, 10, 2, 6, 2, 5, 2, 6, 2, 5, 2, 10, 2, 5, 2, 6]
45+
46+let ErrorOnlyWavesAccepted = "Only waves accepted"
47+
48+let ErrorMustGreaterThan0 = "Parameter size must be greater than 0"
49+
50+let ErrorMustLessThan100 = "Parameter size must be less than 100"
51+
52+let ErrorBetMustBeInWaves = "Bet amount must be in Waves"
53+
54+let ErrorTransactionMustBeInWaves = "Transaction's fee must be in Waves"
55+
56+let ErrorTransactionUsed = "Passed txId had been used before. Game aborted."
57+
58+let ErrorKeyNotFound = "Key not found: "
59+
60+let ErrorGameOver = "Game already is over "
61+
62+let ErrorIncorrectSectionResult = "Incorrect section result"
63+
64+let ErrorBetAmountNotInRange = "Bet amount is not in range"
65+
66+func StoreData (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value)
67+
68+
69+func StoreDataInt (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value)
70+
71+
72+func GetData (key) = match getString(this, key) {
73+ case str: String =>
74+ str
75+ case _ =>
76+ throw((ErrorKeyNotFound + key))
77+}
78+
79+
80+func GetDataString (transactionId,key) = {
81+ let fullKey = ((transactionId + "_") + key)
82+ match getString(this, fullKey) {
83+ case str: String =>
84+ str
85+ case _ =>
86+ throw((ErrorKeyNotFound + fullKey))
87+ }
88+ }
89+
90+
91+func GetDataInt (transactionId,key) = {
92+ let fullKey = ((transactionId + "_") + key)
93+ match getInteger(this, fullKey) {
94+ case str: Int =>
95+ str
96+ case _ =>
97+ throw((ErrorKeyNotFound + fullKey))
98+ }
99+ }
100+
101+
102+func NewGameId () = {
103+ let gameNum = match getInteger(this, DataGameNumberKey) {
104+ case num: Int =>
105+ num
106+ case _ =>
107+ 0
108+ }
109+ (gameNum + 1)
110+ }
111+
112+
113+func GenerateRandInt (gameId,rsaSign) = {
114+ let rsaSigValid = sigVerify(fromBase58String(gameId), fromBase58String(rsaSign), ServerPublicKey)
115+ if (rsaSigValid)
116+ then {
117+ let rand = (toInt(sha256(toBytes(rsaSign))) % RouletteSections)
118+ if ((0 > rand))
119+ then (-1 * rand)
120+ else rand
121+ }
122+ else throw("Invalid RSA signature")
123+ }
124+
125+
126+func GetStatus (result) = if (result)
127+ then DataStatusWin
128+ else DataStatusLoose
129+
130+
131+func GetWinAmount (betAmt,section) = {
132+ let isCorrectResult = if (if (if (if ((section == 2))
133+ then true
134+ else (section == 5))
135+ then true
136+ else (section == 6))
137+ then true
138+ else (section == 10))
139+ then true
140+ else (section == 20)
141+ let betAmtValid = if (if (if (if ((betAmt == (BET1 + COMMISSION)))
142+ then true
143+ else (betAmt == (BET2 + COMMISSION)))
144+ then true
145+ else (betAmt == (BET4 + COMMISSION)))
146+ then true
147+ else (betAmt == (BET8 + COMMISSION)))
148+ then true
149+ else (betAmt == (BET14 + COMMISSION))
150+ if (!(isCorrectResult))
151+ then throw(ErrorIncorrectSectionResult)
152+ else if (betAmtValid)
153+ then ((betAmt - COMMISSION) * section)
154+ else throw(ErrorBetAmountNotInRange)
155+ }
156+
157+
158+@Callable(i)
159+func bet (expectedResult) = {
160+ let gameNumber = NewGameId()
161+ let gameTransactionId = toBase58String(i.transactionId)
162+ let address = toBase58String(i.caller.bytes)
163+ let pmt = extract(i.payment)
164+ let txIdUsed = isDefined(getString(this, gameTransactionId))
165+ let betNotInWaves = isDefined(pmt.assetId)
166+ let feeNotInWaves = isDefined(pmt.assetId)
167+ let amount = pmt.amount
168+ let winAmt = GetWinAmount(pmt.amount, expectedResult)
169+ if (betNotInWaves)
170+ then throw(ErrorBetMustBeInWaves)
171+ else if (feeNotInWaves)
172+ then throw(ErrorTransactionMustBeInWaves)
173+ else if (txIdUsed)
174+ then throw(ErrorTransactionUsed)
175+ else ScriptResult(WriteSet([DataEntry((DataUserGameKey + toString(gameNumber)), gameTransactionId), DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, gameNumber), StoreDataInt(gameTransactionId, DataAmountKey, amount), StoreDataInt(gameTransactionId, DataSectionKey, expectedResult), StoreData(gameTransactionId, DataStatusKey, DataStatusNew), StoreDataInt(gameTransactionId, DataWinAmountKey, winAmt)]), TransferSet([ScriptTransfer(ServerAddress, COMMISSION, unit)]))
176+ }
177+
178+
179+
180+@Callable(i)
181+func result (gameTransactionId,rsa) = {
182+ let randIndex = GenerateRandInt(gameTransactionId, rsa)
183+ let selectedSection = GetDataInt(gameTransactionId, DataSectionKey)
184+ let status = GetDataString(gameTransactionId, DataStatusKey)
185+ if ((status == DataStatusNew))
186+ then {
187+ let randSection = Sections[randIndex]
188+ let isWin = (randSection == selectedSection)
189+ let writeSet = WriteSet([StoreData(gameTransactionId, DataStatusKey, GetStatus(isWin)), StoreDataInt(gameTransactionId, DataResultKey, randSection)])
190+ if (isWin)
191+ then {
192+ let wallet = GetData(gameTransactionId)
193+ let winAmount = GetDataInt(gameTransactionId, DataWinAmountKey)
194+ ScriptResult(writeSet, TransferSet([ScriptTransfer(addressFromStringValue(wallet), winAmount, unit)]))
195+ }
196+ else writeSet
197+ }
198+ else throw((ErrorGameOver + status))
199+ }
200+
201+
202+@Verifier(tx)
203+func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
204+ then match tx {
205+ case ttx: TransferTransaction =>
206+ true
207+ case stx: SetScriptTransaction =>
208+ true
209+ case _ =>
210+ false
211+ }
212+ else false
213+

github/deemru/w8io/026f985 
21.00 ms