tx · DbCVbMezTpESCDTCpMXfr9nRhe4XYJPz53vo8mbkv44B 3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2: -0.01400000 Waves 2019.08.13 10:37 [629010] smart account 3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2 > SELF 0.00000000 Waves
{ "type": 13, "id": "DbCVbMezTpESCDTCpMXfr9nRhe4XYJPz53vo8mbkv44B", "fee": 1400000, "feeAssetId": null, "timestamp": 1565681607069, "version": 1, "sender": "3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2", "senderPublicKey": "F3vhYapU4NBzfM2X4KNkoFcxj3UbYnJjqituG6KE7ZPG", "proofs": [ "37GRmWeXoYjSoqonMhd3hCaT8LW6dkBYgaLBCb8HvDgyiWARmZmgv2isjzZQrf9phdvTJVJBaWh1QRFdp8sAqyTt" ], "script": "base64:AAIDAAAAAAAAAAAAAAAJAAAAAAdSVU5OSU5HAgAAAAdSVU5OSU5HAAAAAAZDTE9TRUQCAAAABkNMT1NFRAAAAAAJREFQUE9XTkVSAgAAACMzTjROUGl2b1RodHNrcjdKeG5OcktMN3M4QnptUkd4OXJUMgAAAAAFV0FWRVMCAAAABVdBVkVTAAAAAAROT05FAgAAAAROT05FAQAAAAtnZXROdW1CeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEGdldENvbnRlc3RTdGF0dXMAAAAABA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aDAFAAAAAnR4AwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24GCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBgZ0PXX2", "chainId": 84, "height": 629010, "spentComplexity": 0 } View: original | compacted Prev: 2ZeaWyXQBgzY1tqbi7YAmMduKG8pLVqvEL5PHW9fhQnt Next: 5Vm3WJvQCq5DxexKXjhwDYufXoL253YnQkgZ5rw3qHCy Diff:
Old | New | Differences | |
---|---|---|---|
121 | 121 | let key = ((("bet_" + toString(contestCurrNumber)) + "_") + currencyRate) | |
122 | 122 | let winnerAccount = getStrByKey(key) | |
123 | 123 | let account = toBase58String(i.caller.bytes) | |
124 | + | let balance = wavesBalance(this) | |
125 | + | let winTransfer = TransferSet([ScriptTransfer(extract(addressFromString(winnerAccount)), wavesBalance(this), unit)]) | |
126 | + | let writeStatistics = WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("contest_" + toString(contestCurrNumber)) + "_winner"), winnerAccount), DataEntry((("contest_" + toString(contestCurrNumber)) + "_currencyrate"), currencyRate), DataEntry((("contest_" + toString(contestCurrNumber)) + "_height"), height)]) | |
124 | 127 | if ((account != DAPPOWNER)) | |
125 | 128 | then throw("Only dAPP Owner can Close Contest.") | |
126 | 129 | else WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("contest_" + toString(contestCurrNumber)) + "_winner"), winnerAccount), DataEntry((("contest_" + toString(contestCurrNumber)) + "_currencyrate"), currencyRate), DataEntry((("contest_" + toString(contestCurrNumber)) + "_height"), height)]) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let RUNNING = "RUNNING" | |
5 | 5 | ||
6 | 6 | let CLOSED = "CLOSED" | |
7 | 7 | ||
8 | 8 | let DAPPOWNER = "3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2" | |
9 | 9 | ||
10 | 10 | let WAVES = "WAVES" | |
11 | 11 | ||
12 | 12 | let NONE = "NONE" | |
13 | 13 | ||
14 | 14 | func getNumByKey (key) = { | |
15 | 15 | let num = match getInteger(this, key) { | |
16 | 16 | case a: Int => | |
17 | 17 | a | |
18 | 18 | case _ => | |
19 | 19 | 0 | |
20 | 20 | } | |
21 | 21 | num | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getStrByKey (key) = { | |
26 | 26 | let str = match getString(this, key) { | |
27 | 27 | case a: String => | |
28 | 28 | a | |
29 | 29 | case _ => | |
30 | 30 | NONE | |
31 | 31 | } | |
32 | 32 | str | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getContestStatus () = { | |
37 | 37 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
38 | 38 | getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func getExtWAVESUSDCurrencyRate () = { | |
43 | 43 | let oracleAddress = extract(addressFromString("3PPTrTo3AzR56N7ArzbU3Bpq9zYMgcf39Mk")) | |
44 | 44 | let WAVESUSDCurrencyRate = match getInteger(oracleAddress, "waves_usd_2") { | |
45 | 45 | case a: Int => | |
46 | 46 | a | |
47 | 47 | case _ => | |
48 | 48 | 0 | |
49 | 49 | } | |
50 | 50 | WAVESUSDCurrencyRate | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | @Callable(i) | |
55 | 55 | func setContestStatus (contestNumber,contestStatus) = { | |
56 | 56 | let account = toBase58String(i.caller.bytes) | |
57 | 57 | if ((account != DAPPOWNER)) | |
58 | 58 | then throw("Only dAPP Owner can set Contest Status.") | |
59 | 59 | else if (if ((contestStatus != RUNNING)) | |
60 | 60 | then (contestStatus != CLOSED) | |
61 | 61 | else false) | |
62 | 62 | then throw(("Invalid status: " + contestStatus)) | |
63 | 63 | else WriteSet([DataEntry((("contest_" + toString(contestNumber)) + "_status"), contestStatus)]) | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(i) | |
69 | 69 | func setContestConfiguration (currencyTicker,contestStartHeight) = { | |
70 | 70 | let account = toBase58String(i.caller.bytes) | |
71 | 71 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
72 | 72 | let contestCurrStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
73 | 73 | let contestNewNumber = (contestCurrNumber + 1) | |
74 | 74 | if ((account != DAPPOWNER)) | |
75 | 75 | then throw("Only dAPP Owner can Configure Contest.") | |
76 | 76 | else if ((height >= contestStartHeight)) | |
77 | 77 | then throw(("Start Height must be greater than current Blockchain height: " + toString(height))) | |
78 | 78 | else if ((contestCurrStatus == RUNNING)) | |
79 | 79 | then throw(("You cannot configure a new Contest while old Contest status is: " + contestCurrStatus)) | |
80 | 80 | else if ((currencyTicker != WAVES)) | |
81 | 81 | then throw((("dAPP does not support currency: " + currencyTicker) + " yet.")) | |
82 | 82 | else { | |
83 | 83 | let contestFinishHeight = (contestStartHeight + (7 * 1440)) | |
84 | 84 | WriteSet([DataEntry("contest_currentnumber", contestNewNumber), DataEntry((("contest_" + toString(contestNewNumber)) + "_currency"), currencyTicker), DataEntry((("contest_" + toString(contestNewNumber)) + "_startheight"), contestStartHeight), DataEntry((("contest_" + toString(contestNewNumber)) + "_finishheight"), contestFinishHeight), DataEntry((("contest_" + toString(contestNewNumber)) + "_status"), RUNNING)]) | |
85 | 85 | } | |
86 | 86 | } | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Callable(i) | |
91 | 91 | func bet (currencyValue) = { | |
92 | 92 | let WLT = base58'FaA6njrtReYVacBjgj36X8gGwydDYQKrthrt3hufhMZh' | |
93 | 93 | let account = toBase58String(i.caller.bytes) | |
94 | 94 | let pmt = extract(i.payment) | |
95 | 95 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
96 | 96 | let contestStartHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_startheight")) | |
97 | 97 | let contestFinishHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_finishheight")) | |
98 | 98 | let key = ((("bet_" + toString(contestCurrNumber)) + "_") + currencyValue) | |
99 | 99 | let contestStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
100 | 100 | let existingBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + currencyValue)) | |
101 | 101 | if ((height > (contestFinishHeight - (2 * 1440)))) | |
102 | 102 | then throw("You cannot bet anymore at this height.") | |
103 | 103 | else if ((contestStatus != RUNNING)) | |
104 | 104 | then throw("Invalid status: you cannot bet now.") | |
105 | 105 | else if (if ((pmt.assetId != WLT)) | |
106 | 106 | then true | |
107 | 107 | else (pmt.amount != 500000)) | |
108 | 108 | then throw("You must pay 5 WLT to bet.") | |
109 | 109 | else if (if ((existingBetAccount != NONE)) | |
110 | 110 | then (existingBetAccount != account) | |
111 | 111 | else false) | |
112 | 112 | then throw(((((((("Key: " + key) + " Account:") + account) + " Existing Bet Account: ") + existingBetAccount) + " Currency Value:") + currencyValue)) | |
113 | 113 | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + currencyValue), account)]) | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | ||
118 | 118 | @Callable(i) | |
119 | 119 | func closecontest (currencyRate) = { | |
120 | 120 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
121 | 121 | let key = ((("bet_" + toString(contestCurrNumber)) + "_") + currencyRate) | |
122 | 122 | let winnerAccount = getStrByKey(key) | |
123 | 123 | let account = toBase58String(i.caller.bytes) | |
124 | + | let balance = wavesBalance(this) | |
125 | + | let winTransfer = TransferSet([ScriptTransfer(extract(addressFromString(winnerAccount)), wavesBalance(this), unit)]) | |
126 | + | let writeStatistics = WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("contest_" + toString(contestCurrNumber)) + "_winner"), winnerAccount), DataEntry((("contest_" + toString(contestCurrNumber)) + "_currencyrate"), currencyRate), DataEntry((("contest_" + toString(contestCurrNumber)) + "_height"), height)]) | |
124 | 127 | if ((account != DAPPOWNER)) | |
125 | 128 | then throw("Only dAPP Owner can Close Contest.") | |
126 | 129 | else WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("contest_" + toString(contestCurrNumber)) + "_winner"), winnerAccount), DataEntry((("contest_" + toString(contestCurrNumber)) + "_currencyrate"), currencyRate), DataEntry((("contest_" + toString(contestCurrNumber)) + "_height"), height)]) | |
127 | 130 | } | |
128 | 131 | ||
129 | 132 | ||
130 | 133 | @Verifier(tx) | |
131 | 134 | func verify () = match tx { | |
132 | 135 | case _: SetScriptTransaction|DataTransaction => | |
133 | 136 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
134 | 137 | case _: InvokeScriptTransaction => | |
135 | 138 | true | |
136 | 139 | case _ => | |
137 | 140 | true | |
138 | 141 | } | |
139 | 142 |
github/deemru/w8io/169f3d6 41.46 ms ◑