tx · Ecsur6jBzNHdsPLssBFXTxAxxPTJpBu28rZvq9fys884

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.09.08 04:37 [666460] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "Ecsur6jBzNHdsPLssBFXTxAxxPTJpBu28rZvq9fys884", "fee": 1400000, "feeAssetId": null, "timestamp": 1567906610267, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "4jGjNZm2YZRz6aXumfE7S5BenWGk84J3A2iN7cpsjBCPE6hYfjFjLb72MC6iVeWa6ioUBGcA9rjhyMnvaWkkuHLF" ], "script": "base64:AAIDAAAAAAAAAAAAAAAPAAAAAAlXaW5TZXJ2ZXIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM045WG55UHBXeFlvaEtIN3o1ZEV1cThycG5vYnB5elByekUAAAAAB1dBVkVMRVQJAABoAAAAAgkAAGgAAAACAAAAAAAAAABkAAAAAAAAAAPoAAAAAAAAAAPoAAAAAApDT01NSVNTSU9OCQAAaQAAAAIJAABoAAAAAgAAAAAAAAAABQUAAAAHV0FWRUxFVAAAAAAAAAAD6AAAAAAOVGlja2V0c1BlcldhdmUAAAAAAAAAAGQAAAAAC0NVUlJFTlRHQU1FAgAAAA0kQ1VSUkVOVF9HQU1FAAAAAA9HQU1FU0NPVU5URVJLRVkCAAAACSRHQU1FX05VTQAAAAAKTEFTVFRJQ0tFVAIAAAAMJExBU1RfVElDS0VUAQAAAA5nZXRQbGF5ZXJzTGlzdAAAAAIAAAAGZ2FtZUlkAAAADWN1cnJlbnRQbGF5ZXIEAAAAEHBsYXllcnNQcmVzZW50ZWQJAQAAAAlpc0RlZmluZWQAAAABCQAEHQA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EAAAAB2JldERhdGEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAC0NVUlJFTlRHQU1FBQAAAAZnYW1lSWQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAD0dBTUVTQ09VTlRFUktFWQUAAAAHZ2FtZU51bQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAFfBQAAABBwbGF5ZXJBZGRyZXNzU3RyAgAAAAhfdGlja2V0cwkBAAAACmdldFRpY2tldHMAAAADBQAAAAZnYW1lSWQFAAAAEHBsYXllckFkZHJlc3NTdHIFAAAACnBheW1lbnRBbXQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAhfcGxheWVycwkBAAAADmdldFBsYXllcnNMaXN0AAAAAgUAAAAGZ2FtZUlkBQAAABBwbGF5ZXJBZGRyZXNzU3RyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApMQVNUVElDS0VUCQEAAAANZ2V0TGFzdFRpY2tldAAAAAEFAAAACnBheW1lbnRBbXQFAAAAA25pbAQAAAALdG9XaW5TZXJ2ZXIJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAJV2luU2VydmVyBQAAAApwYXltZW50QW10BQAAAAR1bml0BQAAAANuaWwJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABBQAAAAdiZXREYXRhCQEAAAALVHJhbnNmZXJTZXQAAAABBQAAAAt0b1dpblNlcnZlcgAAAABkW6FK", "chainId": 84, "height": 666460, "spentComplexity": 0 } View: original | compacted Prev: 2czEBKTtMuub4QwDAHRCcsaiBPthXX4RRisAKGqWYsUA Next: 9neFdVeU3ZQLqUkpaePwb1SPAfHXkGUhMeuUSV9Y8CTj Diff:
OldNewDifferences
3737 }
3838
3939
40+func getOrCreateLastTicket () = {
41+ let isLastTicketPresented = isDefined(getString(this, LASTTICKET))
42+ if (!(isLastTicketPresented))
43+ then 0
44+ else getIntegerValue(this, LASTTICKET)
45+ }
46+
47+
4048 func getTickets (gameId,playerAddressStr,paymentAmt) = {
41- let lastTicket = getIntegerValue(this, LASTTICKET)
49+ let lastTicket = getOrCreateLastTicket()
4250 let wavesPayment = (paymentAmt / WAVELET)
4351 let firstNewTicket = (lastTicket + 1)
4452 let lastNewTicket = (firstNewTicket + (wavesPayment * TicketsPerWave))
5361 }
5462
5563
56-func getOrCreatLastTicket () = {
57- let isLastTicketPresent = isDefined(getString(this, LASTTICKET))
58- if (!(isLastTicketPresent))
59- then 0
60- else getIntegerValue(this, LASTTICKET)
61- }
62-
63-
6464 func getLastTicket (paymentAmt) = {
65- let lastTicket = getOrCreatLastTicket()
65+ let lastTicket = getOrCreateLastTicket()
6666 let wavesPayment = (paymentAmt / WAVELET)
6767 (lastTicket + (wavesPayment * TicketsPerWave))
6868 }
8181 else toString(getIntegerValue(this, GAMESCOUNTERKEY))
8282
8383
84+func getOrCreateCurrentGame (txId) = {
85+ let isCurrentGamePresented = isDefined(getString(this, CURRENTGAME))
86+ if (!(isCurrentGamePresented))
87+ then txId
88+ else getStringValue(this, CURRENTGAME)
89+ }
90+
91+
8492 func getCurrentGame (txId) = {
85- let gameId = getStringValue(this, CURRENTGAME)
93+ let gameId = getOrCreateCurrentGame(txId)
8694 let gameStillOpen = isDefined(getString(this, (gameId + "_result")))
8795 if (gameStillOpen)
8896 then gameId
107115 then throw("Transaction's fee must be in Waves")
108116 else {
109117 let playerAddressStr = toString(playerAddress)
110- let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr)), DataEntry(LASTTICKET, getLastTicket(paymentAmt))]
118+ let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(gameId, playerAddressStr, paymentAmt)), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr)), DataEntry(LASTTICKET, getLastTicket(paymentAmt))]
111119 let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)]
112120 ScriptResult(WriteSet(betData), TransferSet(toWinServer))
113121 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let WinServer = addressFromStringValue("3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE")
55
66 let WAVELET = ((100 * 1000) * 1000)
77
88 let COMMISSION = ((5 * WAVELET) / 1000)
99
1010 let TicketsPerWave = 100
1111
1212 let CURRENTGAME = "$CURRENT_GAME"
1313
1414 let GAMESCOUNTERKEY = "$GAME_NUM"
1515
1616 let LASTTICKET = "$LAST_TICKET"
1717
1818 func getPlayersList (gameId,currentPlayer) = {
1919 let playersPresented = isDefined(getString(this, (gameId + "_players")))
2020 if (!(playersPresented))
2121 then currentPlayer
2222 else if (isDefined(getString(this, (((gameId + "_") + currentPlayer) + "_tickets"))))
2323 then getStringValue(this, (gameId + "_players"))
2424 else ((getStringValue(this, (gameId + "_players")) + "_") + currentPlayer)
2525 }
2626
2727
2828 func FormatGameDataParam (p) = {
2929 let s = size(p)
3030 if ((s == 0))
3131 then throw("Parameter size must be greater then 0")
3232 else if ((s > 99))
3333 then throw("Parameter size must be less then 100")
3434 else if ((10 > s))
3535 then (("0" + toString(s)) + p)
3636 else (toString(s) + p)
3737 }
3838
3939
40+func getOrCreateLastTicket () = {
41+ let isLastTicketPresented = isDefined(getString(this, LASTTICKET))
42+ if (!(isLastTicketPresented))
43+ then 0
44+ else getIntegerValue(this, LASTTICKET)
45+ }
46+
47+
4048 func getTickets (gameId,playerAddressStr,paymentAmt) = {
41- let lastTicket = getIntegerValue(this, LASTTICKET)
49+ let lastTicket = getOrCreateLastTicket()
4250 let wavesPayment = (paymentAmt / WAVELET)
4351 let firstNewTicket = (lastTicket + 1)
4452 let lastNewTicket = (firstNewTicket + (wavesPayment * TicketsPerWave))
4553 let newTickets = ((FormatGameDataParam(toString(firstNewTicket)) + "_") + FormatGameDataParam(toString(lastNewTicket)))
4654 let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets")))
4755 if (ticketsStr)
4856 then {
4957 let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets"))
5058 ((currentTickets + " ") + newTickets)
5159 }
5260 else newTickets
5361 }
5462
5563
56-func getOrCreatLastTicket () = {
57- let isLastTicketPresent = isDefined(getString(this, LASTTICKET))
58- if (!(isLastTicketPresent))
59- then 0
60- else getIntegerValue(this, LASTTICKET)
61- }
62-
63-
6464 func getLastTicket (paymentAmt) = {
65- let lastTicket = getOrCreatLastTicket()
65+ let lastTicket = getOrCreateLastTicket()
6666 let wavesPayment = (paymentAmt / WAVELET)
6767 (lastTicket + (wavesPayment * TicketsPerWave))
6868 }
6969
7070
7171 func IncrementGameNum (gameId,txId) = if ((gameId == txId))
7272 then {
7373 let gameNum = match getInteger(this, GAMESCOUNTERKEY) {
7474 case num: Int =>
7575 num
7676 case _ =>
7777 0
7878 }
7979 toString((gameNum + 1))
8080 }
8181 else toString(getIntegerValue(this, GAMESCOUNTERKEY))
8282
8383
84+func getOrCreateCurrentGame (txId) = {
85+ let isCurrentGamePresented = isDefined(getString(this, CURRENTGAME))
86+ if (!(isCurrentGamePresented))
87+ then txId
88+ else getStringValue(this, CURRENTGAME)
89+ }
90+
91+
8492 func getCurrentGame (txId) = {
85- let gameId = getStringValue(this, CURRENTGAME)
93+ let gameId = getOrCreateCurrentGame(txId)
8694 let gameStillOpen = isDefined(getString(this, (gameId + "_result")))
8795 if (gameStillOpen)
8896 then gameId
8997 else txId
9098 }
9199
92100
93101 @Callable(i)
94102 func bet () = {
95103 let txId = toBase58String(i.transactionId)
96104 let gameId = getCurrentGame(txId)
97105 let gameNum = IncrementGameNum(gameId, txId)
98106 let pmt = extract(i.payment)
99107 let paymentAmt = pmt.amount
100108 let betNotInWaves = isDefined(pmt.assetId)
101109 let feeNotInWaves = isDefined(pmt.assetId)
102110 let playerPubKey58 = toBase58String(i.callerPublicKey)
103111 let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
104112 if (betNotInWaves)
105113 then throw("Bet amount must be in Waves")
106114 else if (feeNotInWaves)
107115 then throw("Transaction's fee must be in Waves")
108116 else {
109117 let playerAddressStr = toString(playerAddress)
110- let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr)), DataEntry(LASTTICKET, getLastTicket(paymentAmt))]
118+ let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(gameId, playerAddressStr, paymentAmt)), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr)), DataEntry(LASTTICKET, getLastTicket(paymentAmt))]
111119 let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)]
112120 ScriptResult(WriteSet(betData), TransferSet(toWinServer))
113121 }
114122 }
115123
116124

github/deemru/w8io/026f985 
49.83 ms