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