tx · DdidCosjvqoP3AM1mWJ4rp2JXEBF2xaasnvRk2Z8TjjJ

3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT:  -0.01400000 Waves

2019.07.01 18:46 [566518] smart account 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT > SELF 0.00000000 Waves

{ "type": 13, "id": "DdidCosjvqoP3AM1mWJ4rp2JXEBF2xaasnvRk2Z8TjjJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1561996056135, "version": 1, "sender": "3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT", "senderPublicKey": "Bhyvkx4xdbEi4KPJNZSzx9gZgzgyLEsavuj2kYSt7SST", "proofs": [ "3BgXeEk2CQak8BXLjYaSKiutVNsH4qyZ5wS78xD55X3g5qeqvZmeMbQpHobeqEDrbR4tmHoUE537EX6ZDiVgRVWS" ], "script": "base64:AAIDAAAAAAAAAAAAAAAnAAAAAA9TZXJ2ZXJQdWJsaWNLZXkBAAAAIL79hxhmqWX34iA/RS9p36FY3qCJjLclClmAz4vj6GlBAAAAAA1TZXJ2ZXJBZGRyZXNzCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNNdThvS1NjV0N3UjMzWW9tVDV1a1U3M1A3akxyeVpUazRzAAAAABBSb3VsZXR0ZVNlY3Rpb25zAAAAAAAAAAAVAAAAABFEYXRhR2FtZU51bWJlcktleQIAAAALQVBQX0dBTUVfSUQAAAAADURhdGFBbW91bnRLZXkCAAAABkFNT1VOVAAAAAAORGF0YVNlY3Rpb25LZXkCAAAAB1NFQ1RJT04AAAAADURhdGFTdGF0dXNLZXkCAAAABlNUQVRVUwAAAAANRGF0YVJlc3VsdEtleQIAAAAGUkVTVUxUAAAAABBEYXRhV2luQW1vdW50S2V5AgAAAApXSU5fQU1PVU5UAAAAAA1EYXRhU3RhdHVzTmV3AgAAAANORVcAAAAADURhdGFTdGF0dXNXaW4CAAAAA1dJTgAAAAAPRGF0YVN0Y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AAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAA3N0eAUAAAAHJG1hdGNoMAYHBwHqFiU=", "chainId": 84, "height": 566518, "spentComplexity": 0 } View: original | compacted Prev: 9iTGABtKnXks19UXagceDxnQxT7dLfgVfALKKj4TKoqm Next: GrV1u2t9T5EnwvykP8swXtZzm6AwgwGgEDZPChq31adD Diff:
OldNewDifferences
6565
6666
6767 func StoreDataInt (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value)
68+
69+
70+func GetData (key) = match getString(this, key) {
71+ case str: String =>
72+ str
73+ case _ =>
74+ throw((ErrorKeyNotFound + key))
75+}
6876
6977
7078 func GetDataString (transactionId,key) = {
171179 let isWin = (rand == selectedSection)
172180 let writeSet = WriteSet([StoreData(gameTransactionId, DataStatusKey, GetStatus(isWin)), StoreDataInt(gameTransactionId, DataResultKey, rand)])
173181 if (isWin)
174- then ScriptResult(writeSet, TransferSet([ScriptTransfer(ServerAddress, COMMISSION, unit)]))
182+ then {
183+ let wallet = GetData(gameTransactionId)
184+ let winAmount = GetDataInt(gameTransactionId, DataWinAmountKey)
185+ ScriptResult(writeSet, TransferSet([ScriptTransfer(addressFromStringValue(wallet), winAmount, unit)]))
186+ }
175187 else writeSet
176188 }
177189 else throw((ErrorGameOver + status))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ServerPublicKey = base58'DrYgfD7j6AKD1iXtn9uhMka95ATZB42B1kGKCUATP2UG'
55
66 let ServerAddress = addressFromStringValue("3Mu8oKScWCwR33YomT5ukU73P7jLryZTk4s")
77
88 let RouletteSections = 21
99
1010 let DataGameNumberKey = "APP_GAME_ID"
1111
1212 let DataAmountKey = "AMOUNT"
1313
1414 let DataSectionKey = "SECTION"
1515
1616 let DataStatusKey = "STATUS"
1717
1818 let DataResultKey = "RESULT"
1919
2020 let DataWinAmountKey = "WIN_AMOUNT"
2121
2222 let DataStatusNew = "NEW"
2323
2424 let DataStatusWin = "WIN"
2525
2626 let DataStatusLoose = "LOOSE"
2727
2828 let WAVELET = ((100 * 1000) * 1000)
2929
3030 let COMMISSION = ((5 * WAVELET) / 1000)
3131
3232 let BET1 = (1 * WAVELET)
3333
3434 let BET2 = (2 * WAVELET)
3535
3636 let BET4 = (4 * WAVELET)
3737
3838 let BET8 = (8 * WAVELET)
3939
4040 let BET14 = (14 * WAVELET)
4141
4242 let Sections = [0, 2, 20, 2, 5, 2, 10, 2, 6, 2, 5, 2, 6, 2, 5, 2, 10, 2, 5, 2, 6]
4343
4444 let ErrorOnlyWavesAccepted = "Only waves accepted"
4545
4646 let ErrorMustGreaterThan0 = "Parameter size must be greater than 0"
4747
4848 let ErrorMustLessThan100 = "Parameter size must be less than 100"
4949
5050 let ErrorBetMustBeInWaves = "Bet amount must be in Waves"
5151
5252 let ErrorTransactionMustBeInWaves = "Transaction's fee must be in Waves"
5353
5454 let ErrorTransactionUsed = "Passed txId had been used before. Game aborted."
5555
5656 let ErrorKeyNotFound = "Key not found: "
5757
5858 let ErrorGameOver = "Game already is over"
5959
6060 let ErrorIncorrectSectionResult = "Incorrect section result"
6161
6262 let ErrorBetAmountNotInRange = "Bet amount is not in range"
6363
6464 func StoreData (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value)
6565
6666
6767 func StoreDataInt (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value)
68+
69+
70+func GetData (key) = match getString(this, key) {
71+ case str: String =>
72+ str
73+ case _ =>
74+ throw((ErrorKeyNotFound + key))
75+}
6876
6977
7078 func GetDataString (transactionId,key) = {
7179 let fullKey = ((transactionId + "_") + key)
7280 match getString(this, fullKey) {
7381 case str: String =>
7482 str
7583 case _ =>
7684 throw((ErrorKeyNotFound + fullKey))
7785 }
7886 }
7987
8088
8189 func GetDataInt (transactionId,key) = {
8290 let fullKey = ((transactionId + "_") + key)
8391 match getInteger(this, fullKey) {
8492 case str: Int =>
8593 str
8694 case _ =>
8795 throw((ErrorKeyNotFound + fullKey))
8896 }
8997 }
9098
9199
92100 func NewGameId () = {
93101 let gameNum = match getInteger(this, DataGameNumberKey) {
94102 case num: Int =>
95103 num
96104 case _ =>
97105 0
98106 }
99107 (gameNum + 1)
100108 }
101109
102110
103111 func GenerateRandInt (gameId,rsaSign) = {
104112 let rsaSigValid = sigVerify(fromBase58String(gameId), fromBase58String(rsaSign), ServerPublicKey)
105113 if (rsaSigValid)
106114 then {
107115 let rand = (toInt(sha256(toBytes(rsaSign))) % RouletteSections)
108116 if ((0 > rand))
109117 then (-1 * rand)
110118 else rand
111119 }
112120 else throw("Invalid RSA signature")
113121 }
114122
115123
116124 func GetStatus (result) = if (result)
117125 then DataStatusWin
118126 else DataStatusLoose
119127
120128
121129 func GetWinAmount (betAmt,section) = {
122130 let isIncorrectResult = if ((0 >= section))
123131 then true
124132 else (section > 20)
125133 let betAmtValid = if (if (if (if ((betAmt == (BET1 + COMMISSION)))
126134 then true
127135 else (betAmt == (BET2 + COMMISSION)))
128136 then true
129137 else (betAmt == (BET4 + COMMISSION)))
130138 then true
131139 else (betAmt == (BET8 + COMMISSION)))
132140 then true
133141 else (betAmt == (BET14 + COMMISSION))
134142 if (isIncorrectResult)
135143 then throw(ErrorIncorrectSectionResult)
136144 else if (betAmtValid)
137145 then ((betAmt - COMMISSION) * Sections[section])
138146 else throw(ErrorBetAmountNotInRange)
139147 }
140148
141149
142150 @Callable(i)
143151 func bet (expectedResult) = {
144152 let gameNumber = NewGameId()
145153 let gameTransactionId = toBase58String(i.transactionId)
146154 let address = toBase58String(i.caller.bytes)
147155 let pmt = extract(i.payment)
148156 let txIdUsed = isDefined(getString(this, gameTransactionId))
149157 let betNotInWaves = isDefined(pmt.assetId)
150158 let feeNotInWaves = isDefined(pmt.assetId)
151159 let amount = pmt.amount
152160 let winAmt = GetWinAmount(pmt.amount, expectedResult)
153161 if (betNotInWaves)
154162 then throw(ErrorBetMustBeInWaves)
155163 else if (feeNotInWaves)
156164 then throw(ErrorTransactionMustBeInWaves)
157165 else if (txIdUsed)
158166 then throw(ErrorTransactionUsed)
159167 else ScriptResult(WriteSet([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)]))
160168 }
161169
162170
163171
164172 @Callable(i)
165173 func result (gameTransactionId,rsa) = {
166174 let rand = GenerateRandInt(gameTransactionId, rsa)
167175 let selectedSection = GetDataInt(gameTransactionId, DataSectionKey)
168176 let status = GetDataString(gameTransactionId, DataStatusKey)
169177 if ((status == DataStatusNew))
170178 then {
171179 let isWin = (rand == selectedSection)
172180 let writeSet = WriteSet([StoreData(gameTransactionId, DataStatusKey, GetStatus(isWin)), StoreDataInt(gameTransactionId, DataResultKey, rand)])
173181 if (isWin)
174- then ScriptResult(writeSet, TransferSet([ScriptTransfer(ServerAddress, COMMISSION, unit)]))
182+ then {
183+ let wallet = GetData(gameTransactionId)
184+ let winAmount = GetDataInt(gameTransactionId, DataWinAmountKey)
185+ ScriptResult(writeSet, TransferSet([ScriptTransfer(addressFromStringValue(wallet), winAmount, unit)]))
186+ }
175187 else writeSet
176188 }
177189 else throw((ErrorGameOver + status))
178190 }
179191
180192
181193 @Verifier(tx)
182194 func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
183195 then match tx {
184196 case stx: SetScriptTransaction =>
185197 true
186198 case _ =>
187199 false
188200 }
189201 else false
190202

github/deemru/w8io/026f985 
28.90 ms