tx · x6Ur9t74Ub8GaRNQXPYK2qJDCFTJ4AcsEt775AxQD6G 3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2: -0.01400000 Waves 2019.08.12 17:56 [627991] smart account 3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2 > SELF 0.00000000 Waves
{ "type": 13, "id": "x6Ur9t74Ub8GaRNQXPYK2qJDCFTJ4AcsEt775AxQD6G", "fee": 1400000, "feeAssetId": null, "timestamp": 1565621831574, "version": 1, "sender": "3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2", "senderPublicKey": "F3vhYapU4NBzfM2X4KNkoFcxj3UbYnJjqituG6KE7ZPG", "proofs": [ "N3rtFDPUYnSDndsrMEXihMoPMqzfDxz74RvbzAgqT9ew7VtJg7gaSBfUN7mHPt57xLeT1T5FBfHpwK79eoUeMnG" ], "script": "base64:AAIDAAAAAAAAAAAAAAAJAAAAAAdSVU5OSU5HAgAAAAdSVU5OSU5HAAAAAAZDTE9TRUQCAAAABkNMT1NFRAAAAAAJREFQUE9XTkVSAgAAACMzTjROUGl2b1RodHNrcjdKeG5OcktMN3M4QnptUkd4OXJUMgAAAAAFV0FWRVMCAAAABVdBVkVTAAAAAAROT05FAgAAAAROT05FAQAAAAtnZXROdW1CeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEGdldENvbnRlc3RTdGF0dXMA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AAAgIAAAAEYmV0XwkAAaQAAAABBQAAABFjb250ZXN0Q3Vyck51bWJlcgIAAAAHX2hlaWdodAUAAAAGaGVpZ2h0BQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBgkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24JAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgYGQ+imoQ==", "chainId": 84, "height": 627991, "spentComplexity": 0 } View: original | compacted Prev: BsK4vUHjh9SPGruGjDDZPa7tazEYdNFYe4K91nwuxhiW Next: novmrkzMULNFH7etZFPEdVBJe3rvfuHfxjid4xmHMXC Diff:
Old | New | Differences | |
---|---|---|---|
68 | 68 | @Callable(i) | |
69 | 69 | func setContestConfiguration (currencyTicker,contestStartHeight) = { | |
70 | 70 | let account = toBase58String(i.caller.bytes) | |
71 | - | let contestPrevNumber = getNumByKey("contest_currentnumber") | |
71 | + | let contestPrevNumber = (getNumByKey("contest_currentnumber") - 1) | |
72 | 72 | let contestPrevStatus = getStrByKey((("contest_" + toString(contestPrevNumber)) + "_status")) | |
73 | 73 | let contestCurrNumber = (contestPrevNumber + 1) | |
74 | 74 | if ((account != DAPPOWNER)) |
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 | - | let contestPrevNumber = getNumByKey("contest_currentnumber") | |
71 | + | let contestPrevNumber = (getNumByKey("contest_currentnumber") - 1) | |
72 | 72 | let contestPrevStatus = getStrByKey((("contest_" + toString(contestPrevNumber)) + "_status")) | |
73 | 73 | let contestCurrNumber = (contestPrevNumber + 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 ((contestPrevStatus == RUNNING)) | |
79 | 79 | then throw(("You cannot configure a new Contest while old Contest status is: " + contestPrevStatus)) | |
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", contestCurrNumber), DataEntry((("contest_" + toString(contestCurrNumber)) + "_currency"), currencyTicker), DataEntry((("contest_" + toString(contestCurrNumber)) + "_startheight"), contestStartHeight), DataEntry((("contest_" + toString(contestCurrNumber)) + "_finishheight"), contestFinishHeight), DataEntry((("contest_" + toString(contestCurrNumber)) + "_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 | 124 | if ((account != DAPPOWNER)) | |
125 | 125 | then throw("Only dAPP Owner can Close Contest.") | |
126 | 126 | else WriteSet([DataEntry((("bet_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("bet_" + toString(contestCurrNumber)) + "_winner"), winnerAccount), DataEntry((("bet_" + toString(contestCurrNumber)) + "_currencyrate"), currencyRate), DataEntry((("bet_" + toString(contestCurrNumber)) + "_height"), height)]) | |
127 | 127 | } | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | @Verifier(tx) | |
131 | 131 | func verify () = match tx { | |
132 | 132 | case _: SetScriptTransaction|DataTransaction => | |
133 | 133 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
134 | 134 | case _: InvokeScriptTransaction => | |
135 | 135 | true | |
136 | 136 | case _ => | |
137 | 137 | true | |
138 | 138 | } | |
139 | 139 |
github/deemru/w8io/169f3d6 34.17 ms ◑