tx · DDSQWoYuEzcbQ2WZqy2SiQ7u2DV8RRYjDZdchZUxCMz4

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.09.08 04:30 [666450] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "DDSQWoYuEzcbQ2WZqy2SiQ7u2DV8RRYjDZdchZUxCMz4", "fee": 1400000, "feeAssetId": null, "timestamp": 1567906257584, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "4f63XUFFY8syriEs2HuAsKBeS6EGexRYizRjoA1AUGKDrcLSkhXLqon7h9a8GceaDR6XihYhEuHZ7fd1sBMihxea" ], "script": "base64:AAIDAAAAAAAAAAAAAAAOAAAAAAlXaW5TZXJ2ZXIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM045WG55UHBXeFlvaEtIN3o1ZEV1cThycG5vYnB5elByekUAAAAAB1dBVkVMRVQJAABoAAAAAgkAAGgAAAACAAAAAAAAAABkAAAAAAAAAAPoAAAAAAAAAAPoAAAAAApDT01NSVNTSU9OCQAAaQAAAAIJAABoAAAAAgAAAAAAAAAABQUAAAAHV0FWRUxFVAAAAAAAAAAD6AAAAAAOVGlja2V0c1BlcldhdmUAAAAAAAAAAGQAAAAAC0NVUlJFTlRHQU1FAgAAAA0kQ1VSUkVOVF9HQU1FAAAAAA9HQU1FU0NPVU5URVJLRVkCAAAACSRHQU1FX05VTQAAAAAKTEFTVFRJQ0tFVAIAAAAMJExBU1RfVElDS0VUAQAAAA5nZXRQbGF5ZXJzTGlzdAAAAAIAAAAGZ2FtZUlkAAAADWN1cnJlbnRQbGF5ZXIEAAAAEHBsYXllcnNQcmVzZW50ZWQJAQAAAAlpc0RlZmluZWQAAAAB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Z2V0TGFzdFRpY2tldAAAAAEFAAAACnBheW1lbnRBbXQFAAAAA25pbAQAAAALdG9XaW5TZXJ2ZXIJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAJV2luU2VydmVyBQAAAApwYXltZW50QW10BQAAAAR1bml0BQAAAANuaWwJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABBQAAAAdiZXREYXRhCQEAAAALVHJhbnNmZXJTZXQAAAABBQAAAAt0b1dpblNlcnZlcgAAAAAHu8z2", "chainId": 84, "height": 666450, "spentComplexity": 0 } View: original | compacted Prev: DgwParyWMXzWJmSQxmDSPSYto3bfbotMZMz3zgBdWmKd Next: 2czEBKTtMuub4QwDAHRCcsaiBPthXX4RRisAKGqWYsUA Diff:
OldNewDifferences
5353 }
5454
5555
56+func getOrCreatLastTicket () = {
57+ let isLastTicketPresent = isDefined(getString(this, LASTTICKET))
58+ if (!(isLastTicketPresent))
59+ then 0
60+ else getIntegerValue(this, LASTTICKET)
61+ }
62+
63+
5664 func getLastTicket (paymentAmt) = {
57- let lastTicket = getIntegerValue(this, LASTTICKET)
65+ let lastTicket = getOrCreatLastTicket()
5866 let wavesPayment = (paymentAmt / WAVELET)
5967 (lastTicket + (wavesPayment * TicketsPerWave))
6068 }
99107 then throw("Transaction's fee must be in Waves")
100108 else {
101109 let playerAddressStr = toString(playerAddress)
102- let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum)]
110+ let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry(LASTTICKET, getLastTicket(paymentAmt))]
103111 let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)]
104112 ScriptResult(WriteSet(betData), TransferSet(toWinServer))
105113 }
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
4040 func getTickets (gameId,playerAddressStr,paymentAmt) = {
4141 let lastTicket = getIntegerValue(this, LASTTICKET)
4242 let wavesPayment = (paymentAmt / WAVELET)
4343 let firstNewTicket = (lastTicket + 1)
4444 let lastNewTicket = (firstNewTicket + (wavesPayment * TicketsPerWave))
4545 let newTickets = ((FormatGameDataParam(toString(firstNewTicket)) + "_") + FormatGameDataParam(toString(lastNewTicket)))
4646 let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets")))
4747 if (ticketsStr)
4848 then {
4949 let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets"))
5050 ((currentTickets + " ") + newTickets)
5151 }
5252 else newTickets
5353 }
5454
5555
56+func getOrCreatLastTicket () = {
57+ let isLastTicketPresent = isDefined(getString(this, LASTTICKET))
58+ if (!(isLastTicketPresent))
59+ then 0
60+ else getIntegerValue(this, LASTTICKET)
61+ }
62+
63+
5664 func getLastTicket (paymentAmt) = {
57- let lastTicket = getIntegerValue(this, LASTTICKET)
65+ let lastTicket = getOrCreatLastTicket()
5866 let wavesPayment = (paymentAmt / WAVELET)
5967 (lastTicket + (wavesPayment * TicketsPerWave))
6068 }
6169
6270
6371 func IncrementGameNum (gameId,txId) = if ((gameId == txId))
6472 then {
6573 let gameNum = match getInteger(this, GAMESCOUNTERKEY) {
6674 case num: Int =>
6775 num
6876 case _ =>
6977 0
7078 }
7179 toString((gameNum + 1))
7280 }
7381 else toString(getIntegerValue(this, GAMESCOUNTERKEY))
7482
7583
7684 func getCurrentGame (txId) = {
7785 let gameId = getStringValue(this, CURRENTGAME)
7886 let gameStillOpen = isDefined(getString(this, (gameId + "_result")))
7987 if (gameStillOpen)
8088 then gameId
8189 else txId
8290 }
8391
8492
8593 @Callable(i)
8694 func bet () = {
8795 let txId = toBase58String(i.transactionId)
8896 let gameId = getCurrentGame(txId)
8997 let gameNum = IncrementGameNum(gameId, txId)
9098 let pmt = extract(i.payment)
9199 let paymentAmt = pmt.amount
92100 let betNotInWaves = isDefined(pmt.assetId)
93101 let feeNotInWaves = isDefined(pmt.assetId)
94102 let playerPubKey58 = toBase58String(i.callerPublicKey)
95103 let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
96104 if (betNotInWaves)
97105 then throw("Bet amount must be in Waves")
98106 else if (feeNotInWaves)
99107 then throw("Transaction's fee must be in Waves")
100108 else {
101109 let playerAddressStr = toString(playerAddress)
102- let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum)]
110+ let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry(LASTTICKET, getLastTicket(paymentAmt))]
103111 let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)]
104112 ScriptResult(WriteSet(betData), TransferSet(toWinServer))
105113 }
106114 }
107115
108116

github/deemru/w8io/026f985 
37.62 ms