tx · GTzbatcbQzwCFmDwSEtuCbtGoJq8pvRi7e293TXrdpXE

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.09.08 04:38 [666464] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "GTzbatcbQzwCFmDwSEtuCbtGoJq8pvRi7e293TXrdpXE", "fee": 1400000, "feeAssetId": null, "timestamp": 1567906753204, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "3mRMgtnHcNLYFiKmzPPY87cvcQUeCBfhVwhUQ5i1rdb6uAQAKEnLiLugAi8Tv5FmEKYEAs97kzoyKbZccejMq91h" ], "script": "base64:AAIDAAAAAAAAAAAAAAAPAAAAAAlXaW5TZXJ2ZXIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM045WG55UHBXeFlvaEtIN3o1ZEV1cThycG5vYnB5elByekUAAAAAB1dBVkVMRVQJAABoAAAAAgkAAGgAAAACAAAAAAAAAABkAAAAAAAAAAPoAAAAAAAAAAPoAAAAAApDT01NSVNTSU9OCQAAaQAAAAIJAABoAAAAAgAAAAAAAAAABQUAAAAHV0FWRUxFVAAAAAAAAAAD6AAAAAAOVGlja2V0c1BlcldhdmUAAAAAAAAAAGQAAAAAC0NVUlJFTlRHQU1FAgAAAA0kQ1VSUkVOVF9HQU1FAAAAAA9HQU1FU0NPVU5URVJLRVkCAAAACSRHQU1FX05VTQAAAAAKTEFTVFRJQ0tFVAIAAAAMJExBU1RfVElDS0VUAQAAAA5nZXRQbGF5ZXJzTGlzdAAAAAIAAAAGZ2FtZUlkAAAADWN1cnJlbnRQbGF5ZXIEAAAAEHBsYXllcnNQcmVzZW50ZWQJAQAAAAlpc0RlZmluZWQAAAABCQA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XllckFkZHJlc3NTdHIJAAQlAAAAAQUAAAANcGxheWVyQWRkcmVzcwQAAAAHYmV0RGF0YQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAALQ1VSUkVOVEdBTUUFAAAABmdhbWVJZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAPR0FNRVNDT1VOVEVSS0VZBQAAAAdnYW1lTnVtCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZnYW1lSWQCAAAAAV8FAAAAEHBsYXllckFkZHJlc3NTdHICAAAACF90aWNrZXRzCQEAAAAKZ2V0VGlja2V0cwAAAAMFAAAABmdhbWVJZAUAAAAQcGxheWVyQWRkcmVzc1N0cgUAAAAKcGF5bWVudEFtdAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZnYW1lSWQCAAAACF9wbGF5ZXJzCQEAAAAOZ2V0UGxheWVyc0xpc3QAAAACBQAAAAZnYW1lSWQFAAAAEHBsYXllckFkZHJlc3NTdHIJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACkxBU1RUSUNLRVQJAQAAAA1nZXRMYXN0VGlja2V0AAAAAQUAAAAKcGF5bWVudEFtdAUAAAADbmlsBAAAAAt0b1dpblNlcnZlcgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAlXaW5TZXJ2ZXIFAAAACnBheW1lbnRBbXQFAAAABHVuaXQFAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEFAAAAB2JldERhdGEJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAAC3RvV2luU2VydmVyAAAAADBOFfM=", "chainId": 84, "height": 666464, "spentComplexity": 0 } View: original | compacted Prev: 9neFdVeU3ZQLqUkpaePwb1SPAfHXkGUhMeuUSV9Y8CTj Next: 2tr2h2PdH4osh7f7y87w7zUjDEszabV6rLJ2ZLFXaEjW 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 getOrCreateLastTicket () = {
4141 let isLastTicketPresented = isDefined(getString(this, LASTTICKET))
4242 if (!(isLastTicketPresented))
4343 then 0
4444 else getIntegerValue(this, LASTTICKET)
4545 }
4646
4747
4848 func getTickets (gameId,playerAddressStr,paymentAmt) = {
4949 let lastTicket = getOrCreateLastTicket()
5050 let wavesPayment = (paymentAmt / WAVELET)
5151 let firstNewTicket = (lastTicket + 1)
5252 let lastNewTicket = ((firstNewTicket + (wavesPayment * TicketsPerWave)) - 1)
5353 let newTickets = ((FormatGameDataParam(toString(firstNewTicket)) + "_") + FormatGameDataParam(toString(lastNewTicket)))
5454 let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets")))
5555 if (ticketsStr)
5656 then {
5757 let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets"))
5858 ((currentTickets + " ") + newTickets)
5959 }
6060 else newTickets
6161 }
6262
6363
6464 func getLastTicket (paymentAmt) = {
6565 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
8484 func getOrCreateCurrentGame (txId) = {
8585 let isCurrentGamePresented = isDefined(getString(this, CURRENTGAME))
8686 if (!(isCurrentGamePresented))
8787 then txId
8888 else getStringValue(this, CURRENTGAME)
8989 }
9090
9191
9292 func getCurrentGame (txId) = {
9393 let gameId = getOrCreateCurrentGame(txId)
9494 let gameStillOpen = isDefined(getString(this, (gameId + "_result")))
9595 if (gameStillOpen)
9696 then gameId
9797 else txId
9898 }
9999
100100
101101 @Callable(i)
102102 func bet () = {
103103 let txId = toBase58String(i.transactionId)
104104 let gameId = getCurrentGame(txId)
105105 let gameNum = IncrementGameNum(gameId, txId)
106106 let pmt = extract(i.payment)
107107 let paymentAmt = pmt.amount
108108 let betNotInWaves = isDefined(pmt.assetId)
109109 let feeNotInWaves = isDefined(pmt.assetId)
110110 let playerPubKey58 = toBase58String(i.callerPublicKey)
111111 let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
112112 if (betNotInWaves)
113113 then throw("Bet amount must be in Waves")
114114 else if (feeNotInWaves)
115115 then throw("Transaction's fee must be in Waves")
116116 else {
117117 let playerAddressStr = toString(playerAddress)
118118 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))]
119119 let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)]
120120 ScriptResult(WriteSet(betData), TransferSet(toWinServer))
121121 }
122122 }
123123
124124

github/deemru/w8io/026f985 
36.68 ms