tx · npn3zUSY7zetmEtDjeh9MMkHej2pe1GN59bzsMT6nsL 3N86AryjXNvAuNs3mV9xKPTjXnAYQimiHDF: -0.01000000 Waves 2023.09.18 14:09 [2760748] smart account 3N86AryjXNvAuNs3mV9xKPTjXnAYQimiHDF > SELF 0.00000000 Waves
{ "type": 13, "id": "npn3zUSY7zetmEtDjeh9MMkHej2pe1GN59bzsMT6nsL", "fee": 1000000, "feeAssetId": null, "timestamp": 1695035443553, "version": 2, "chainId": 84, "sender": "3N86AryjXNvAuNs3mV9xKPTjXnAYQimiHDF", "senderPublicKey": "7Zo8C4qkZishvcPg5SUixQPySKeM49Jeui21Tih7iPr9", "proofs": [ "5ZHAMesmvzXcwvwJSvGR3Np11Ys4JAsTzLJqBKvAZXXS3rXCLjyHJDDco4z3eUi796Mgi1bGJTMaXta28HHkrGPH" ], "script": "base64:BgIVCAISABIDCgEBEgQKAggIEgQKAgEEFQADU0VQAgJfXwAPcmVwdXRhdGlvbkFzc2V0ASBp6x+DcpBVAG0dTZ5QIAuA7CaS8wuiEOK6KQOBSERbTgAMcHJvcG9zYWxUaW1lCQBoAgkAaAIJAGgCCQBoAgDoBwA8ADwAGAADARJ1bmxvY2tUaW1lc3RhbXBLZXkBB2FkZHJlc3MJALkJAgkAzAgCAgJ1dAkAzAgCCQDYBAEFB2FkZHJlc3MFA25pbAUDU0VQARFjb3VudFByb3Bvc2Fsc0tleQACAmNwARBwcm9wb3NhbFRpdGxlS2V5AQJpZAkAuQkCCQDMCAICA3B0aQkAzAgCCQCkAwEFAmlkBQNuaWwFA1NFUAEPcHJvcG9zYWxUZXh0S2V5AQJpZAkAuQkCCQDMCAICA3B0ZQkAzAgCCQCkAwEFAmlkBQNuaWwFA1NFUAEccHJvcG9zYWxUaW1lc3RhbXBDcmVhdGlvbktleQECaWQJALkJAgkAzAgCAgNwdGMJAMwIAgkApAMBBQJpZAUDbmlsBQNTRVABGHByb3Bvc2FsQ291bnRWb3Rlc0ZvcktleQECaWQJALkJAgk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bnRyeQIJARN1c2VyUHJvcG9zYWxWb3RlS2V5AggIBQFpBmNhbGxlcgVieXRlcwUCaWQFBHZvdGUJAMwIAgkBDEludGVnZXJFbnRyeQIJARh1c2VyUHJvcG9zYWxWb3RlUG93ZXJLZXkCCAgFAWkGY2FsbGVyBWJ5dGVzBQJpZAkBFmJhbGFuY2VSZXB1dGF0aW9uQXNzZXQBCAgFAWkGY2FsbGVyBWJ5dGVzBQNuaWwJAMwIAgkBDEludGVnZXJFbnRyeQIJARxwcm9wb3NhbENvdW50Vm90ZXNBZ2FpbnN0S2V5AQUCaWQJAGQCCQERY291bnRWb3Rlc0FnYWluc3QBBQJpZAkBFmJhbGFuY2VSZXB1dGF0aW9uQXNzZXQBCAgFAWkGY2FsbGVyBWJ5dGVzCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQESdW5sb2NrVGltZXN0YW1wS2V5AQgIBQFpBmNhbGxlcgVieXRlcwUKdW5sb2NrVGltZQkAzAgCCQEMQm9vbGVhbkVudHJ5AgkBE3VzZXJQcm9wb3NhbFZvdGVLZXkCCAgFAWkGY2FsbGVyBWJ5dGVzBQJpZAUEdm90ZQkAzAgCCQEMSW50ZWdlckVudHJ5AgkBGHVzZXJQcm9wb3NhbFZvdGVQb3dlcktleQIICAUBaQZjYWxsZXIFYnl0ZXMFAmlkCQEWYmFsYW5jZVJlcHV0YXRpb25Bc3NldAEICAUBaQZjYWxsZXIFYnl0ZXMFA25pbAkAAgECEHByb3Bvc2FsTm90QWxpdmUBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V54Dd+WQ==", "height": 2760748, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 3b6YjoVMye43yA3vMbLB12odXsBhdWNVAD7fze31aWNR Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let reputationAsset = base58'88Tkdpqchhiqc9tNNG3SWQ2gfhZB4rBJKhMNS5Xmxhqw' | |
7 | + | ||
8 | + | let proposalTime = ((((1000 * 60) * 60) * 24) * 3) | |
9 | + | ||
10 | + | func unlockTimestampKey (address) = makeString(["ut", toBase58String(address)], SEP) | |
11 | + | ||
12 | + | ||
13 | + | func countProposalsKey () = "cp" | |
14 | + | ||
15 | + | ||
16 | + | func proposalTitleKey (id) = makeString(["pti", toString(id)], SEP) | |
17 | + | ||
18 | + | ||
19 | + | func proposalTextKey (id) = makeString(["pte", toString(id)], SEP) | |
20 | + | ||
21 | + | ||
22 | + | func proposalTimestampCreationKey (id) = makeString(["ptc", toString(id)], SEP) | |
23 | + | ||
24 | + | ||
25 | + | func proposalCountVotesForKey (id) = makeString(["pcvf", toString(id)], SEP) | |
26 | + | ||
27 | + | ||
28 | + | func proposalCountVotesAgainstKey (id) = makeString(["pcva", toString(id)], SEP) | |
29 | + | ||
30 | + | ||
31 | + | func userProposalVoteKey (address,id) = makeString(["upv", toString(id), toBase58String(address)], SEP) | |
32 | + | ||
33 | + | ||
34 | + | func userProposalVotePowerKey (address,id) = makeString(["upvp", toString(id), toBase58String(address)], SEP) | |
35 | + | ||
36 | + | ||
37 | + | func pmtReputationAsset (i) = if ((size(i.payments) == 1)) | |
38 | + | then if ((i.payments[0].assetId == reputationAsset)) | |
39 | + | then true | |
40 | + | else throw("only reputation assets") | |
41 | + | else throw("only 1 payment") | |
42 | + | ||
43 | + | ||
44 | + | func getUnlockTimestamp (address) = match getInteger(this, unlockTimestampKey(address)) { | |
45 | + | case a: Int => | |
46 | + | a | |
47 | + | case _ => | |
48 | + | 0 | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | func countProposals () = match getInteger(this, countProposalsKey()) { | |
53 | + | case a: Int => | |
54 | + | a | |
55 | + | case _ => | |
56 | + | 0 | |
57 | + | } | |
58 | + | ||
59 | + | ||
60 | + | func countVotesFor (id) = match getInteger(this, proposalCountVotesForKey(id)) { | |
61 | + | case a: Int => | |
62 | + | a | |
63 | + | case _ => | |
64 | + | 0 | |
65 | + | } | |
66 | + | ||
67 | + | ||
68 | + | func countVotesAgainst (id) = match getInteger(this, proposalCountVotesAgainstKey(id)) { | |
69 | + | case a: Int => | |
70 | + | a | |
71 | + | case _ => | |
72 | + | 0 | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | func countVotesUser (address,id) = match getInteger(this, userProposalVotePowerKey(address, id)) { | |
77 | + | case a: Int => | |
78 | + | a | |
79 | + | case _ => | |
80 | + | 0 | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | func balanceReputationAsset (address) = match getInteger(this, toBase58String(address)) { | |
85 | + | case a: Int => | |
86 | + | a | |
87 | + | case _ => | |
88 | + | 0 | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | func proposalTimestampCreation (id) = match getInteger(this, proposalTimestampCreationKey(id)) { | |
93 | + | case a: Int => | |
94 | + | a | |
95 | + | case _ => | |
96 | + | throw("proposal not created") | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | func isProposalAlive (id) = if (if ((countProposals() > id)) | |
101 | + | then ((proposalTimestampCreation(id) + proposalTime) > lastBlock.timestamp) | |
102 | + | else false) | |
103 | + | then true | |
104 | + | else throw("proposalNotAlive") | |
105 | + | ||
106 | + | ||
107 | + | @Callable(i) | |
108 | + | func deposit () = { | |
109 | + | let checks = [pmtReputationAsset(i)] | |
110 | + | if ((checks == checks)) | |
111 | + | then { | |
112 | + | let currentKey = toBase58String(i.caller.bytes) | |
113 | + | let currentAmount = balanceReputationAsset(i.caller.bytes) | |
114 | + | let newAmount = (currentAmount + i.payments[0].amount) | |
115 | + | [IntegerEntry(currentKey, newAmount)] | |
116 | + | } | |
117 | + | else throw("onlyReputationAsset") | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func withdraw (amount) = { | |
124 | + | let currentKey = toBase58String(i.caller.bytes) | |
125 | + | let currentAmount = match getInteger(this, currentKey) { | |
126 | + | case a: Int => | |
127 | + | a | |
128 | + | case _ => | |
129 | + | 0 | |
130 | + | } | |
131 | + | let newAmount = (currentAmount - amount) | |
132 | + | if ((0 > amount)) | |
133 | + | then throw("Can't withdraw negative amount") | |
134 | + | else if ((getUnlockTimestamp(i.caller.bytes) > lastBlock.timestamp)) | |
135 | + | then throw("Locked") | |
136 | + | else if ((0 > newAmount)) | |
137 | + | then throw("Not enough balance") | |
138 | + | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, reputationAsset)] | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | ||
143 | + | @Callable(i) | |
144 | + | func createProposal (title,text) = { | |
145 | + | let count = countProposals() | |
146 | + | [StringEntry(proposalTitleKey(count), title), StringEntry(proposalTextKey(count), text), IntegerEntry(proposalTimestampCreationKey(count), lastBlock.timestamp), IntegerEntry(countProposalsKey(), (count + 1))] | |
147 | + | } | |
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | @Callable(i) | |
152 | + | func vote (id,vote) = if (isProposalAlive(id)) | |
153 | + | then { | |
154 | + | let unlockTime = max([(proposalTimestampCreation(id) + proposalTime), getUnlockTimestamp(i.caller.bytes)]) | |
155 | + | let u = match getBoolean(this, userProposalVoteKey(i.caller.bytes, id)) { | |
156 | + | case a: Boolean => | |
157 | + | if (a) | |
158 | + | then IntegerEntry(proposalCountVotesForKey(id), (countVotesFor(id) - countVotesUser(i.caller.bytes, id))) | |
159 | + | else IntegerEntry(proposalCountVotesAgainstKey(id), (countVotesFor(id) - countVotesUser(i.caller.bytes, id))) | |
160 | + | case _ => | |
161 | + | unit | |
162 | + | } | |
163 | + | if ((vote == true)) | |
164 | + | then [IntegerEntry(proposalCountVotesForKey(id), (countVotesFor(id) + balanceReputationAsset(i.caller.bytes))), IntegerEntry(unlockTimestampKey(i.caller.bytes), unlockTime), BooleanEntry(userProposalVoteKey(i.caller.bytes, id), vote), IntegerEntry(userProposalVotePowerKey(i.caller.bytes, id), balanceReputationAsset(i.caller.bytes))] | |
165 | + | else [IntegerEntry(proposalCountVotesAgainstKey(id), (countVotesAgainst(id) + balanceReputationAsset(i.caller.bytes))), IntegerEntry(unlockTimestampKey(i.caller.bytes), unlockTime), BooleanEntry(userProposalVoteKey(i.caller.bytes, id), vote), IntegerEntry(userProposalVotePowerKey(i.caller.bytes, id), balanceReputationAsset(i.caller.bytes))] | |
166 | + | } | |
167 | + | else throw("proposalNotAlive") | |
168 | + | ||
169 | + | ||
170 | + | @Verifier(tx) | |
171 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
172 | + |
github/deemru/w8io/026f985 23.87 ms ◑