tx · 4Xgs92tEEYbCYmRww2REc3iY4fEDSPiHobZ1g8R6WUBS

3Mt6NEJ6ZK6TFZs14tvnR5iAgemnomy2m1V:  -0.00700000 Waves

2022.08.31 22:06 [2209027] smart account 3Mt6NEJ6ZK6TFZs14tvnR5iAgemnomy2m1V > SELF 0.00000000 Waves

{ "type": 13, "id": "4Xgs92tEEYbCYmRww2REc3iY4fEDSPiHobZ1g8R6WUBS", "fee": 700000, "feeAssetId": null, "timestamp": 1661972836720, "version": 2, "chainId": 84, "sender": "3Mt6NEJ6ZK6TFZs14tvnR5iAgemnomy2m1V", "senderPublicKey": "5f9EawB8nxaLg7KKhyqV2RDBMwRBG6o69D8zc9myAzrY", "proofs": [ "2RyZdaboRJ36qgPBY9hSqWbHfJWcKNJPsrPZcdwQnudtN29f9nn5bP9RYwAk2JKrorgf2VuLgfBfwjCNG1eTeYar" ], "script": "base64:AAIFAAAAAAAAABAIAhIAEgASABIAEgASABIAAAAAGgAAAAAOZ2FtZVRva2VuTGFiZWwCAAAACUdfVE9LRU5JRAAAAAAQZ2FtZUJhbGFuY2VMYWJlbAIAAAAJR19CQUxBTkNFAAAAABVnYW1lQ29tbXVuaXR5UG90TGFiZWwCAAAADkdfQ09NTVVOSVRZUE9UAAAAABFnYW1lUHJpemVQb3RMYWJlbAIAAAAKR19QUklaRVBPVAAAAAAZZ2FtZVByaXplU2hhcmVBbW91bnRMYWJlbAIAAAASR19QUklaRVNIQVJFQU1PVU5UAAAAABBnYW1lQ291bnRlckxhYmVsAgAAAA5HX0dBTUVTQ09VTlRFUgAAAAASZ2FtZVRvdGFsQmV0c0xhYmVsAgAAAAtHX1RPVEFMQkVUUwAAAAAWZ2FtZVByb2Nlc3NlZEJldHNMYWJlbAIAAAAPR19QUk9DRVNTRURCRVRTAAAAABdnYW1lV2lubmVyc0NvdW50ZXJMYWJlbAIAAAAOR19XSU5ORVJTQ09VTlQAAAAAGWdhbWVQcm9jZXNzZWRXaW5uZXJzTGFiZWwCAAAAEkd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AAAAByRtYXRjaDIJAQAAABRnYW1lUHJpemVTaGFyZUFtb3VudAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDICAAAAA0ludAQAAAAQcHJpemVTaGFyZUFtb3VudAUAAAAHJG1hdGNoMgQAAAAJYmV0UGxhY2VyCQEAAAANd2lubmVyRGV0YWlscwAAAAEFAAAACm5leHRXaW5uZXIEAAAAB2FkZHJlc3MJAQAAAAV2YWx1ZQAAAAEJAAQmAAAAAQUAAAAJYmV0UGxhY2VyBAAAAAh3aW5uaW5ncwkBAAAAFGdhbWVQcml6ZVNoYXJlQW1vdW50AAAAAAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAdhZGRyZXNzBQAAABBwcml6ZVNoYXJlQW1vdW50CQEAAAAJZ2FtZVRva2VuAAAAAAUAAAADbmlsCQAAAgAAAAECAAAAO0dhbWUgaGFzIG5vdCBiZWVuIGluaXRpYWxpemVkLCBwcml6ZSBzaGFyZSBhbW91bnQgbm90IGZvdW5kCQAAAgAAAAECAAAAQEdhbWUgaGFzIG5vdCBiZWVuIGluaXRpYWxpemVkLCB0b3RhbCBwcm9jZXNzZWQgd2lubmVycyBub3QgZm91bmQJAAACAAAAAQIAAAA2R2FtZSBoYXMgbm90IGJlZW4gaW5pdGlhbGl6ZWQsIHRvdGFsIHdpbm5lcnMgbm90IGZvdW5kAAAAAI2f7BU=", "height": 2209027, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G82eTsvCbwMs9V4Z74omAjt4fPtSzibv7VzzseJAm9xJ Next: 59pAUTAXhHGoTvkSJCWrRWBHbWcfBUyoUbn84kR1cMPG Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let gameTokenLabel = "G_TOKENID"
5+
6+let gameBalanceLabel = "G_BALANCE"
7+
8+let gameCommunityPotLabel = "G_COMMUNITYPOT"
9+
10+let gamePrizePotLabel = "G_PRIZEPOT"
11+
12+let gamePrizeShareAmountLabel = "G_PRIZESHAREAMOUNT"
13+
414 let gameCounterLabel = "G_GAMESCOUNTER"
515
616 let gameTotalBetsLabel = "G_TOTALBETS"
919
1020 let gameWinnersCounterLabel = "G_WINNERSCOUNT"
1121
22+let gameProcessedWinnersLabel = "G_PROCESSEDWINNERS"
23+
1224 func gameResultLabel (gameNumber) = (("G_" + toString(gameNumber)) + "_RESULT")
1325
1426
1628
1729
1830 func winnerDetailsLabel (winnerNumber) = (("W_" + toString(winnerNumber)) + "_WINNERDETAILS")
31+
32+
33+func gameBalance () = getInteger(this, gameBalanceLabel)
34+
35+
36+func gameCommunityPot () = getInteger(this, gameCommunityPotLabel)
37+
38+
39+func gamePrizePot () = getInteger(this, gamePrizePotLabel)
40+
41+
42+func gamePrizeShareAmount () = getInteger(this, gamePrizeShareAmountLabel)
1943
2044
2145 func gamesGetCounter () = getInteger(this, gameCounterLabel)
3054 func gameWinnersCounter () = getInteger(this, gameWinnersCounterLabel)
3155
3256
57+func gameProcessedWinners () = getInteger(this, gameProcessedWinnersLabel)
58+
59+
3360 func gameGetResult (gameNumber) = getStringValue(this, gameResultLabel(gameNumber))
3461
3562
3966 func winnerDetails (winnerNumber) = getStringValue(this, winnerDetailsLabel(winnerNumber))
4067
4168
69+func gameToken () = match getString(this, gameTokenLabel) {
70+ case tokenId: String =>
71+ if ((tokenId == ""))
72+ then unit
73+ else fromBase58String(tokenId)
74+ case _ =>
75+ unit
76+}
77+
78+
4279 @Callable(i)
43-func initGame () = [IntegerEntry(gameCounterLabel, 0), IntegerEntry(gameTotalBetsLabel, 0), IntegerEntry(gameProcessedBetsLabel, 0), IntegerEntry(gameWinnersCounterLabel, 0)]
80+func initGame () = [IntegerEntry(gameBalanceLabel, 0), IntegerEntry(gameCommunityPotLabel, 0), IntegerEntry(gamePrizePotLabel, 10000000), IntegerEntry(gamePrizeShareAmountLabel, 0), IntegerEntry(gameCounterLabel, 0), IntegerEntry(gameTotalBetsLabel, 0), IntegerEntry(gameProcessedBetsLabel, 0), IntegerEntry(gameWinnersCounterLabel, 0)]
4481
4582
4683
87124 case totalBets: Int =>
88125 match gameProcessedBets() {
89126 case lastProcessedBet: Int =>
90- match gameWinnersCounter() {
91- case winnersCount: Int =>
92- let nextBet = (lastProcessedBet + 1)
93- if ((nextBet > totalBets))
94- then throw("Next bet has not been placed.")
95- else {
96- let gameNumber = gamesGetCounter()
97- let result = gameGetResult(1)
98- let betDetail = betDetails(nextBet)
99- if ((betDetail == result))
100- then {
101- let newWinnersCount = (winnersCount + 1)
102-[IntegerEntry(gameProcessedBetsLabel, nextBet), IntegerEntry(gameWinnersCounterLabel, (winnersCount + 1)), StringEntry(winnerDetailsLabel(newWinnersCount), ("B_" + toString(nextBet)))]
103- }
104- else [IntegerEntry(gameProcessedBetsLabel, nextBet)]
105- }
106- case _ =>
107- throw("Game has not been initialized, total winners not found")
108- }
127+ let nextBet = (lastProcessedBet + 1)
128+ if ((nextBet > totalBets))
129+ then throw("Next bet has not been placed.")
130+ else match gamesGetCounter() {
131+ case gameNumber: Int =>
132+ match gameWinnersCounter() {
133+ case winnersCount: Int =>
134+ let result = gameGetResult(gameNumber)
135+ let betDetail = betDetails(nextBet)
136+ if ((betDetail == result))
137+ then {
138+ let newWinnersCount = (winnersCount + 1)
139+[IntegerEntry(gameProcessedBetsLabel, nextBet), IntegerEntry(gameWinnersCounterLabel, (winnersCount + 1)), StringEntry(winnerDetailsLabel(newWinnersCount), toBase58String(i.caller.bytes))]
140+ }
141+ else [IntegerEntry(gameProcessedBetsLabel, nextBet)]
142+ case _ =>
143+ throw("Game has not been initialized, total winners not found")
144+ }
145+ case _ =>
146+ throw("Game has not been initialized, total games not found")
147+ }
109148 case _ =>
110149 throw("Game has not been initialized, total processed bets not found")
111150 }
114153 }
115154
116155
156+
157+@Callable(i)
158+func calculatePrize () = match gameWinnersCounter() {
159+ case winnersCount: Int =>
160+ if ((winnersCount == 0))
161+ then throw("There are no winners this round.")
162+ else match gamePrizePot() {
163+ case prizePotAmount: Int =>
164+ let prizePot = gamePrizePot()
165+ let prizeShareAmount = (prizePotAmount / winnersCount)
166+[IntegerEntry(gamePrizeShareAmountLabel, prizeShareAmount)]
167+ case _ =>
168+ throw("Game has not been initialized, total games not found")
169+ }
170+ case _ =>
171+ throw("Game has not been initialized, total winners not found")
172+}
173+
174+
175+
176+@Callable(i)
177+func processNextWinner () = match gameWinnersCounter() {
178+ case totalWinners: Int =>
179+ if ((totalWinners == 0))
180+ then throw("There are no winners this round.")
181+ else match gameProcessedWinners() {
182+ case lastProcessedWinner: Int =>
183+ let nextWinner = (lastProcessedWinner + 1)
184+ if ((nextWinner > totalWinners))
185+ then throw("No more winners to be processed.")
186+ else match gamePrizeShareAmount() {
187+ case prizeShareAmount: Int =>
188+ let betPlacer = winnerDetails(nextWinner)
189+ let address = value(addressFromString(betPlacer))
190+ let winnings = gamePrizeShareAmount()
191+[ScriptTransfer(address, prizeShareAmount, gameToken())]
192+ case _ =>
193+ throw("Game has not been initialized, prize share amount not found")
194+ }
195+ case _ =>
196+ throw("Game has not been initialized, total processed winners not found")
197+ }
198+ case _ =>
199+ throw("Game has not been initialized, total winners not found")
200+}
201+
202+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let gameTokenLabel = "G_TOKENID"
5+
6+let gameBalanceLabel = "G_BALANCE"
7+
8+let gameCommunityPotLabel = "G_COMMUNITYPOT"
9+
10+let gamePrizePotLabel = "G_PRIZEPOT"
11+
12+let gamePrizeShareAmountLabel = "G_PRIZESHAREAMOUNT"
13+
414 let gameCounterLabel = "G_GAMESCOUNTER"
515
616 let gameTotalBetsLabel = "G_TOTALBETS"
717
818 let gameProcessedBetsLabel = "G_PROCESSEDBETS"
919
1020 let gameWinnersCounterLabel = "G_WINNERSCOUNT"
1121
22+let gameProcessedWinnersLabel = "G_PROCESSEDWINNERS"
23+
1224 func gameResultLabel (gameNumber) = (("G_" + toString(gameNumber)) + "_RESULT")
1325
1426
1527 func betDetailsLabel (betNumber) = (("B_" + toString(betNumber)) + "_BETDETAILS")
1628
1729
1830 func winnerDetailsLabel (winnerNumber) = (("W_" + toString(winnerNumber)) + "_WINNERDETAILS")
31+
32+
33+func gameBalance () = getInteger(this, gameBalanceLabel)
34+
35+
36+func gameCommunityPot () = getInteger(this, gameCommunityPotLabel)
37+
38+
39+func gamePrizePot () = getInteger(this, gamePrizePotLabel)
40+
41+
42+func gamePrizeShareAmount () = getInteger(this, gamePrizeShareAmountLabel)
1943
2044
2145 func gamesGetCounter () = getInteger(this, gameCounterLabel)
2246
2347
2448 func gameTotalBets () = getInteger(this, gameTotalBetsLabel)
2549
2650
2751 func gameProcessedBets () = getInteger(this, gameProcessedBetsLabel)
2852
2953
3054 func gameWinnersCounter () = getInteger(this, gameWinnersCounterLabel)
3155
3256
57+func gameProcessedWinners () = getInteger(this, gameProcessedWinnersLabel)
58+
59+
3360 func gameGetResult (gameNumber) = getStringValue(this, gameResultLabel(gameNumber))
3461
3562
3663 func betDetails (betNumber) = getStringValue(this, betDetailsLabel(betNumber))
3764
3865
3966 func winnerDetails (winnerNumber) = getStringValue(this, winnerDetailsLabel(winnerNumber))
4067
4168
69+func gameToken () = match getString(this, gameTokenLabel) {
70+ case tokenId: String =>
71+ if ((tokenId == ""))
72+ then unit
73+ else fromBase58String(tokenId)
74+ case _ =>
75+ unit
76+}
77+
78+
4279 @Callable(i)
43-func initGame () = [IntegerEntry(gameCounterLabel, 0), IntegerEntry(gameTotalBetsLabel, 0), IntegerEntry(gameProcessedBetsLabel, 0), IntegerEntry(gameWinnersCounterLabel, 0)]
80+func initGame () = [IntegerEntry(gameBalanceLabel, 0), IntegerEntry(gameCommunityPotLabel, 0), IntegerEntry(gamePrizePotLabel, 10000000), IntegerEntry(gamePrizeShareAmountLabel, 0), IntegerEntry(gameCounterLabel, 0), IntegerEntry(gameTotalBetsLabel, 0), IntegerEntry(gameProcessedBetsLabel, 0), IntegerEntry(gameWinnersCounterLabel, 0)]
4481
4582
4683
4784 @Callable(i)
4885 func startGame () = match gamesGetCounter() {
4986 case currentGame: Int =>
5087 let newGame = (currentGame + 1)
5188 [IntegerEntry(gameCounterLabel, newGame)]
5289 case _ =>
5390 throw("Game has not been initialized, total games not found")
5491 }
5592
5693
5794
5895 @Callable(i)
5996 func placeBet () = match gamesGetCounter() {
6097 case currentGame: Int =>
6198 match gameTotalBets() {
6299 case totalBets: Int =>
63100 let newBet = (totalBets + 1)
64101 let bet = "1,2,3"
65102 [IntegerEntry(gameTotalBetsLabel, newBet), StringEntry(betDetailsLabel(newBet), ((("G" + toString(currentGame)) + "-") + bet))]
66103 case _ =>
67104 throw("Game has not been initialized, total bets not found")
68105 }
69106 case _ =>
70107 throw("Game has not been initialized, total games not found")
71108 }
72109
73110
74111
75112 @Callable(i)
76113 func endGame () = match gamesGetCounter() {
77114 case currentGame: Int =>
78115 [StringEntry(gameResultLabel(currentGame), ((("G" + toString(currentGame)) + "-") + "1,2,3"))]
79116 case _ =>
80117 throw("Game has not been initialized, total games not found")
81118 }
82119
83120
84121
85122 @Callable(i)
86123 func processNextBet () = match gameTotalBets() {
87124 case totalBets: Int =>
88125 match gameProcessedBets() {
89126 case lastProcessedBet: Int =>
90- match gameWinnersCounter() {
91- case winnersCount: Int =>
92- let nextBet = (lastProcessedBet + 1)
93- if ((nextBet > totalBets))
94- then throw("Next bet has not been placed.")
95- else {
96- let gameNumber = gamesGetCounter()
97- let result = gameGetResult(1)
98- let betDetail = betDetails(nextBet)
99- if ((betDetail == result))
100- then {
101- let newWinnersCount = (winnersCount + 1)
102-[IntegerEntry(gameProcessedBetsLabel, nextBet), IntegerEntry(gameWinnersCounterLabel, (winnersCount + 1)), StringEntry(winnerDetailsLabel(newWinnersCount), ("B_" + toString(nextBet)))]
103- }
104- else [IntegerEntry(gameProcessedBetsLabel, nextBet)]
105- }
106- case _ =>
107- throw("Game has not been initialized, total winners not found")
108- }
127+ let nextBet = (lastProcessedBet + 1)
128+ if ((nextBet > totalBets))
129+ then throw("Next bet has not been placed.")
130+ else match gamesGetCounter() {
131+ case gameNumber: Int =>
132+ match gameWinnersCounter() {
133+ case winnersCount: Int =>
134+ let result = gameGetResult(gameNumber)
135+ let betDetail = betDetails(nextBet)
136+ if ((betDetail == result))
137+ then {
138+ let newWinnersCount = (winnersCount + 1)
139+[IntegerEntry(gameProcessedBetsLabel, nextBet), IntegerEntry(gameWinnersCounterLabel, (winnersCount + 1)), StringEntry(winnerDetailsLabel(newWinnersCount), toBase58String(i.caller.bytes))]
140+ }
141+ else [IntegerEntry(gameProcessedBetsLabel, nextBet)]
142+ case _ =>
143+ throw("Game has not been initialized, total winners not found")
144+ }
145+ case _ =>
146+ throw("Game has not been initialized, total games not found")
147+ }
109148 case _ =>
110149 throw("Game has not been initialized, total processed bets not found")
111150 }
112151 case _ =>
113152 throw("Game has not been initialized, total bets not found")
114153 }
115154
116155
156+
157+@Callable(i)
158+func calculatePrize () = match gameWinnersCounter() {
159+ case winnersCount: Int =>
160+ if ((winnersCount == 0))
161+ then throw("There are no winners this round.")
162+ else match gamePrizePot() {
163+ case prizePotAmount: Int =>
164+ let prizePot = gamePrizePot()
165+ let prizeShareAmount = (prizePotAmount / winnersCount)
166+[IntegerEntry(gamePrizeShareAmountLabel, prizeShareAmount)]
167+ case _ =>
168+ throw("Game has not been initialized, total games not found")
169+ }
170+ case _ =>
171+ throw("Game has not been initialized, total winners not found")
172+}
173+
174+
175+
176+@Callable(i)
177+func processNextWinner () = match gameWinnersCounter() {
178+ case totalWinners: Int =>
179+ if ((totalWinners == 0))
180+ then throw("There are no winners this round.")
181+ else match gameProcessedWinners() {
182+ case lastProcessedWinner: Int =>
183+ let nextWinner = (lastProcessedWinner + 1)
184+ if ((nextWinner > totalWinners))
185+ then throw("No more winners to be processed.")
186+ else match gamePrizeShareAmount() {
187+ case prizeShareAmount: Int =>
188+ let betPlacer = winnerDetails(nextWinner)
189+ let address = value(addressFromString(betPlacer))
190+ let winnings = gamePrizeShareAmount()
191+[ScriptTransfer(address, prizeShareAmount, gameToken())]
192+ case _ =>
193+ throw("Game has not been initialized, prize share amount not found")
194+ }
195+ case _ =>
196+ throw("Game has not been initialized, total processed winners not found")
197+ }
198+ case _ =>
199+ throw("Game has not been initialized, total winners not found")
200+}
201+
202+

github/deemru/w8io/169f3d6 
29.46 ms