tx · 7mfewmr5sE4CsPrjX2LXvqQ8d9W1wU3CxVUYP9ETLxHJ

3Mttoccgkeiiy6UDNxZgRryjbHDhtNSG8hk:  -0.01400000 Waves

2019.07.28 00:27 [605003] smart account 3Mttoccgkeiiy6UDNxZgRryjbHDhtNSG8hk > SELF 0.00000000 Waves

{ "type": 13, "id": "7mfewmr5sE4CsPrjX2LXvqQ8d9W1wU3CxVUYP9ETLxHJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1564262856817, "version": 1, "sender": "3Mttoccgkeiiy6UDNxZgRryjbHDhtNSG8hk", "senderPublicKey": "85Agsd1kzDDGoNw1gnh5KHdzJBTckBemuSqfn9v9YyB1", "proofs": [ "y68hzMkBbrMy7o4n3U4Vzud66Hkyvw5roQB5q18rX1P9k8KBfttCHTYsiLeixy9gBtGpqh6M7MncHFndf516js3" ], "script": null, "chainId": 84, "height": 605003, "spentComplexity": 0 } View: original | compacted Prev: D5RFZz77GySkohJkWShWdux3Zmwbahcg2oYWzdbfmDdD Next: BR3V2xeJ2KaZHQqH71YpoPKbMDkqDGF98GEswoCCWqUG Full:
OldNewDifferences
1-{-# STDLIB_VERSION 3 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let ownerPublicKey = base58'9UUaVVahBUyLHLQo4HNuQsRMKY9QBH43Grojkbdf4wG4'
5-
6-let destinationWalletAddressDataKey = "destination_wallet_address"
7-
8-let btcCurrency = "btc"
9-
10-let ethCurrency = "eth"
11-
12-let wavesCurrency = "waves"
13-
14-let ltcCurrency = "ltc"
15-
16-func getDestinationWalletAddress () = match getString(this, destinationWalletAddressDataKey) {
17- case v: String =>
18- if ((v == ""))
19- then throw("Destination wallet address cannot be empty")
20- else addressFromStringValue(v)
21- case _ =>
22- throw("Destination wallet address undefined")
23-}
24-
25-
26-func getCancelBetDataKey (raceId,playerAddress) = (((raceId + "_") + playerAddress) + "_canceled")
27-
28-
29-func getBetDataKey (raceId,playerAddress,currency) = (((((raceId + "_player_") + playerAddress) + "_bet_") + currency) + "_amount")
30-
31-
32-func getShareSumDataKey (raceId,playerAddress,currency) = (((((raceId + "_player_") + playerAddress) + "_") + currency) + "_share_sum")
33-
34-
35-func getTotalBetDataKey (raceId) = (raceId + "_total_bet_amount")
36-
37-
38-func getPlacePlayerAddressDataKey (raceId,placeIndex) = (((raceId + "_") + toString(placeIndex)) + "_place_player_address")
39-
40-
41-func getStartPriceDataKey (raceId,currency) = (((raceId + "_") + currency) + "_start_price")
42-
43-
44-func getEndPriceDataKey (raceId,currency) = (((raceId + "_") + currency) + "_end_price")
45-
46-
47-func checkBetCanceled (raceId,playerAddress) = match getBoolean(this, getCancelBetDataKey(toString(raceId), playerAddress)) {
48- case v: Boolean =>
49- throw("Bet already canceled")
50- case _ =>
51- false
52-}
53-
54-
55-@Callable(i)
56-func setDestinationWallet (address) = if ((i.callerPublicKey != ownerPublicKey))
57- then throw("Only owner can call this method")
58- else if ((address == ""))
59- then throw("Address cannot be empty")
60- else WriteSet([DataEntry(destinationWalletAddressDataKey, address)])
61-
62-
63-
64-@Callable(i)
65-func bet (raceId,portfolioBtcShareSum,portfolioEthShareSum,portfolioWavesShareSum,portfolioLtcShareSum,signature) = {
66- let raceIdStr = toString(raceId)
67- let payment = extract(i.payment)
68- let betAmount = payment.amount
69- let callerAddressStr = toBase58String(i.caller.bytes)
70- let r = checkBetCanceled(raceId, callerAddressStr)
71- let validatingDataStr = ((((((raceIdStr + callerAddressStr) + toString(betAmount)) + toString(portfolioBtcShareSum)) + toString(portfolioEthShareSum)) + toString(portfolioWavesShareSum)) + toString(portfolioLtcShareSum))
72- if (!(sigVerify(toBytes(validatingDataStr), toBytes(signature), ownerPublicKey)))
73- then throw("Cannot verify signature")
74- else {
75- let totalBetAmount = match getInteger(this, getTotalBetDataKey(raceIdStr)) {
76- case v: Int =>
77- v
78- case _ =>
79- 0
80- }
81- let newTotalBetAmount = (totalBetAmount + betAmount)
82- WriteSet([DataEntry(getTotalBetDataKey(raceIdStr), totalBetAmount), DataEntry(getCancelBetDataKey(raceIdStr, callerAddressStr), betAmount), DataEntry(getShareSumDataKey(raceIdStr, callerAddressStr, btcCurrency), portfolioBtcShareSum), DataEntry(getShareSumDataKey(raceIdStr, callerAddressStr, ethCurrency), portfolioEthShareSum), DataEntry(getShareSumDataKey(raceIdStr, callerAddressStr, wavesCurrency), portfolioWavesShareSum), DataEntry(getShareSumDataKey(raceIdStr, callerAddressStr, ltcCurrency), portfolioLtcShareSum)])
83- }
84- }
85-
86-
87-
88-@Callable(i)
89-func cancelBet (raceId,signature) = {
90- let raceIdStr = toString(raceId)
91- let callerAddressStr = toBase58String(i.caller.bytes)
92- let r = checkBetCanceled(raceId, callerAddressStr)
93- let validatingDataStr = (toString(raceId) + callerAddressStr)
94- if (!(sigVerify(toBytes(validatingDataStr), signature, ownerPublicKey)))
95- then throw("Cannot verify signature")
96- else {
97- let totalBetDataKey = getTotalBetDataKey(raceIdStr)
98- let playerBetAmount = getIntegerValue(this, getBetDataKey(raceIdStr, callerAddressStr, wavesCurrency))
99- let currentTotalBetAmount = getIntegerValue(this, totalBetDataKey)
100- let newTotalBetAmount = (currentTotalBetAmount - playerBetAmount)
101- if ((0 > newTotalBetAmount))
102- then throw("New state of total bet will be less than zero, state error")
103- else ScriptResult(WriteSet([DataEntry(getCancelBetDataKey(raceIdStr, callerAddressStr), true), DataEntry(totalBetDataKey, newTotalBetAmount)]), TransferSet([ScriptTransfer(addressFromStringValue(callerAddressStr), playerBetAmount, unit)]))
104- }
105- }
106-
107-
108-
109-@Callable(i)
110-func endRace (id,firstPlacePlayerAddress,secondPlacePlayerAddress,thirdPlacePlayerAddress,btcStartPrice,btcEndPrice,ethStartPrice,ethEndPrice,wavesStartPrice,wavesEndPrice,ltcStartPrice,ltcEndPrice) = if ((i.callerPublicKey != ownerPublicKey))
111- then throw("Only owner can call endRace")
112- else {
113- let raceIdStr = toString(id)
114- let totalBetAmount = getIntegerValue(this, getTotalBetDataKey(raceIdStr))
115- let firstPlacePlayerDepositAmount = getIntegerValue(this, getBetDataKey(raceIdStr, firstPlacePlayerAddress, wavesCurrency))
116- let secondPlacePlayerDepositAmount = getIntegerValue(this, getBetDataKey(raceIdStr, secondPlacePlayerAddress, wavesCurrency))
117- let thirdPlacePlayerDepositAmount = getIntegerValue(this, getBetDataKey(raceIdStr, thirdPlacePlayerAddress, wavesCurrency))
118- let firstPlacePrizeAmount = (firstPlacePlayerDepositAmount * 2)
119- let secondPlacePrizeAmount = ((secondPlacePlayerDepositAmount * 3) / 2)
120- let thirdPlacePrizeAmount = thirdPlacePlayerDepositAmount
121- let commissionAmount = (totalBetAmount - ((firstPlacePrizeAmount + secondPlacePrizeAmount) + thirdPlacePrizeAmount))
122- if ((0 >= commissionAmount))
123- then throw("Commission must be greater than zero, state error")
124- else {
125- let currentAmount = wavesBalance(this)
126- let newAmount = (currentAmount - commissionAmount)
127- if ((0 > newAmount))
128- then throw("Not enough funds in core account")
129- else ScriptResult(WriteSet([DataEntry(getPlacePlayerAddressDataKey(raceIdStr, 1), firstPlacePlayerAddress), DataEntry(getPlacePlayerAddressDataKey(raceIdStr, 2), secondPlacePlayerAddress), DataEntry(getPlacePlayerAddressDataKey(raceIdStr, 3), thirdPlacePlayerAddress), DataEntry(getStartPriceDataKey(raceIdStr, btcCurrency), btcStartPrice), DataEntry(getEndPriceDataKey(raceIdStr, btcCurrency), btcEndPrice), DataEntry(getStartPriceDataKey(raceIdStr, ethCurrency), ethStartPrice), DataEntry(getEndPriceDataKey(raceIdStr, ethCurrency), ethEndPrice), DataEntry(getStartPriceDataKey(raceIdStr, wavesCurrency), wavesStartPrice), DataEntry(getEndPriceDataKey(raceIdStr, wavesCurrency), wavesEndPrice), DataEntry(getStartPriceDataKey(raceIdStr, ltcCurrency), ltcStartPrice), DataEntry(getEndPriceDataKey(raceIdStr, ltcCurrency), ltcEndPrice)]), TransferSet([ScriptTransfer(addressFromStringValue(firstPlacePlayerAddress), firstPlacePrizeAmount, unit), ScriptTransfer(addressFromStringValue(secondPlacePlayerAddress), secondPlacePrizeAmount, unit), ScriptTransfer(addressFromStringValue(thirdPlacePlayerAddress), thirdPlacePrizeAmount, unit), ScriptTransfer(getDestinationWalletAddress(), commissionAmount, unit)]))
130- }
131- }
132-
133-
1+# no script

github/deemru/w8io/873ac7e 
17.52 ms