tx · 32qsTgxx1aTMzvupms8e8DT2nUht88BvHGKzJrqh3Vd5 3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun: -0.01400000 Waves 2019.09.08 07:40 [666639] smart account 3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun > SELF 0.00000000 Waves
{ "type": 13, "id": "32qsTgxx1aTMzvupms8e8DT2nUht88BvHGKzJrqh3Vd5", "fee": 1400000, "feeAssetId": null, "timestamp": 1567917129579, "version": 1, "sender": "3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun", "senderPublicKey": "7uRSDXQUkUS7719CDA4wXghhzsWrF22gb18FGDPZyA6P", "proofs": [ "5wKQutbkQD4g1dmoRY4DbgUoSQGjTpqKBrieYWMG2m2JkHsKutULg7mcKQ3oL8Ntvv9gyT27cDt1TNwBxn4tqBfp" ], "script": "base64:AAIDAAAAAAAAAAAAAAAPAAAAAAlXaW5TZXJ2ZXIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM045WG55UHBXeFlvaEtIN3o1ZEV1cThycG5vYnB5elByekUAAAAAB1dBVkVMRVQJAABoAAAAAgkAAGgAAAACAAAAAAAAAABkAAAAAAAAAAPoAAAAAAAAAAPoAAAAAApDT01NSVNTSU9OCQAAaQAAAAIJAABoAAAAAgAAAAAAAAAABQUAAAAHV0FWRUxFVAAAAAAAAAAD6AAAAAAOVGlja2V0c1BlcldhdmUAAAAAAAAAAGQAAAAAC0NVUlJFTlRHQU1FAgAAAA0kQ1VSUkVOVF9HQU1FAAAAAA9HQU1FU0NPVU5URVJLRVkCAAAACSRHQU1FX05VTQAAAAAKTEFTVFRJQ0tFVAIAAAAMJExBU1RfVElDS0VUAQAAAA5nZXRQbGF5ZXJzTGlzdAAAAAIAAAAGZ2FtZUlkAAAADWN1cnJlbnRQbGF5ZXIEAAAAEHBsYXllcnNQcmVzZW50ZWQJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFA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AAAAAgUAAAAGZ2FtZUlkAgAAAAFfBQAAABBwbGF5ZXJBZGRyZXNzU3RyAgAAAAhfdGlja2V0cwkBAAAACmdldFRpY2tldHMAAAADBQAAAAZnYW1lSWQFAAAAEHBsYXllckFkZHJlc3NTdHIFAAAACnBheW1lbnRBbXQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAhfcGxheWVycwkBAAAADmdldFBsYXllcnNMaXN0AAAAAgUAAAAGZ2FtZUlkBQAAABBwbGF5ZXJBZGRyZXNzU3RyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApMQVNUVElDS0VUCQEAAAANZ2V0TGFzdFRpY2tldAAAAAEFAAAACnBheW1lbnRBbXQFAAAAA25pbAQAAAALdG9XaW5TZXJ2ZXIJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAJV2luU2VydmVyBQAAAApwYXltZW50QW10BQAAAAR1bml0BQAAAANuaWwJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABBQAAAAdiZXREYXRhCQEAAAALVHJhbnNmZXJTZXQAAAABBQAAAAt0b1dpblNlcnZlcgAAAACvT5MX", "chainId": 84, "height": 666639, "spentComplexity": 0 } View: original | compacted Prev: none Next: CyA88LXvvL7V7Z6igTx4qK4bBM1sq3vi2nAgmDmJ1DY9 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let WinServer = addressFromStringValue("3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE") | |
5 | + | ||
6 | + | let WAVELET = ((100 * 1000) * 1000) | |
7 | + | ||
8 | + | let COMMISSION = ((5 * WAVELET) / 1000) | |
9 | + | ||
10 | + | let TicketsPerWave = 100 | |
11 | + | ||
12 | + | let CURRENTGAME = "$CURRENT_GAME" | |
13 | + | ||
14 | + | let GAMESCOUNTERKEY = "$GAME_NUM" | |
15 | + | ||
16 | + | let LASTTICKET = "$LAST_TICKET" | |
17 | + | ||
18 | + | func getPlayersList (gameId,currentPlayer) = { | |
19 | + | let playersPresented = isDefined(getString(this, (gameId + "_players"))) | |
20 | + | if (!(playersPresented)) | |
21 | + | then currentPlayer | |
22 | + | else if (isDefined(getString(this, (((gameId + "_") + currentPlayer) + "_tickets")))) | |
23 | + | then getStringValue(this, (gameId + "_players")) | |
24 | + | else ((getStringValue(this, (gameId + "_players")) + "_") + currentPlayer) | |
25 | + | } | |
26 | + | ||
27 | + | ||
28 | + | func FormatGameDataParam (p) = { | |
29 | + | let s = size(p) | |
30 | + | if ((s == 0)) | |
31 | + | then throw("Parameter size must be greater then 0") | |
32 | + | else if ((s > 99)) | |
33 | + | then throw("Parameter size must be less then 100") | |
34 | + | else if ((10 > s)) | |
35 | + | then (("0" + toString(s)) + p) | |
36 | + | else (toString(s) + p) | |
37 | + | } | |
38 | + | ||
39 | + | ||
40 | + | func getOrCreateLastTicket () = { | |
41 | + | let isLastTicketPresented = isDefined(getInteger(this, LASTTICKET)) | |
42 | + | if (!(isLastTicketPresented)) | |
43 | + | then 0 | |
44 | + | else getIntegerValue(this, LASTTICKET) | |
45 | + | } | |
46 | + | ||
47 | + | ||
48 | + | func getTickets (gameId,playerAddressStr,paymentAmt) = { | |
49 | + | let lastTicket = getOrCreateLastTicket() | |
50 | + | let wavesPayment = (paymentAmt / WAVELET) | |
51 | + | let firstNewTicket = (lastTicket + 1) | |
52 | + | let lastNewTicket = ((firstNewTicket + (wavesPayment * TicketsPerWave)) - 1) | |
53 | + | let newTickets = ((FormatGameDataParam(toString(firstNewTicket)) + "_") + FormatGameDataParam(toString(lastNewTicket))) | |
54 | + | let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets"))) | |
55 | + | if (ticketsStr) | |
56 | + | then { | |
57 | + | let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets")) | |
58 | + | ((currentTickets + " ") + newTickets) | |
59 | + | } | |
60 | + | else newTickets | |
61 | + | } | |
62 | + | ||
63 | + | ||
64 | + | func getLastTicket (paymentAmt) = { | |
65 | + | let lastTicket = getOrCreateLastTicket() | |
66 | + | let wavesPayment = (paymentAmt / WAVELET) | |
67 | + | (lastTicket + (wavesPayment * TicketsPerWave)) | |
68 | + | } | |
69 | + | ||
70 | + | ||
71 | + | func IncrementGameNum (gameId,txId) = { | |
72 | + | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
73 | + | case num: Int => | |
74 | + | num | |
75 | + | case _ => | |
76 | + | 0 | |
77 | + | } | |
78 | + | if ((gameId == txId)) | |
79 | + | then (gameNum + 1) | |
80 | + | else gameNum | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | func getOrCreateCurrentGame (txId) = { | |
85 | + | let isCurrentGamePresented = isDefined(getString(this, CURRENTGAME)) | |
86 | + | if (!(isCurrentGamePresented)) | |
87 | + | then txId | |
88 | + | else if ((getStringValue(this, CURRENTGAME) == "")) | |
89 | + | then txId | |
90 | + | else getStringValue(this, CURRENTGAME) | |
91 | + | } | |
92 | + | ||
93 | + | ||
94 | + | func getCurrentGame (txId) = { | |
95 | + | let gameId = getOrCreateCurrentGame(txId) | |
96 | + | let gameAlreadyPlayed = isDefined(getString(this, (gameId + "_result"))) | |
97 | + | if (gameAlreadyPlayed) | |
98 | + | then txId | |
99 | + | else gameId | |
100 | + | } | |
101 | + | ||
102 | + | ||
103 | + | @Callable(i) | |
104 | + | func resetGameData (gameId) = { | |
105 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
106 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
107 | + | let playerAddressStr = toString(playerAddress) | |
108 | + | let zeroData = [DataEntry(CURRENTGAME, ""), DataEntry(GAMESCOUNTERKEY, 0), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), ""), DataEntry((gameId + "_players"), ""), DataEntry(LASTTICKET, 0)] | |
109 | + | WriteSet(zeroData) | |
110 | + | } | |
111 | + | ||
112 | + | ||
113 | + | ||
114 | + | @Callable(i) | |
115 | + | func bet () = { | |
116 | + | let txId = toBase58String(i.transactionId) | |
117 | + | let gameId = getCurrentGame(txId) | |
118 | + | let gameNum = IncrementGameNum(gameId, txId) | |
119 | + | let pmt = extract(i.payment) | |
120 | + | let paymentAmt = pmt.amount | |
121 | + | let betNotInWaves = isDefined(pmt.assetId) | |
122 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
123 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
124 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
125 | + | if (betNotInWaves) | |
126 | + | then throw("Bet amount must be in Waves") | |
127 | + | else if (feeNotInWaves) | |
128 | + | then throw("Transaction's fee must be in Waves") | |
129 | + | else { | |
130 | + | let playerAddressStr = toString(playerAddress) | |
131 | + | 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))] | |
132 | + | let toWinServer = [ScriptTransfer(WinServer, paymentAmt, unit)] | |
133 | + | ScriptResult(WriteSet(betData), TransferSet(toWinServer)) | |
134 | + | } | |
135 | + | } | |
136 | + | ||
137 | + |
github/deemru/w8io/026f985 17.54 ms ◑