tx · Dz14xVuLDy3xWNhWvpZEWDsbGm9v1eCQCtPfRki7jd1p 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu: -0.01400000 Waves 2020.11.12 10:52 [1261866] smart account 3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu > SELF 0.00000000 Waves
{ "type": 13, "id": "Dz14xVuLDy3xWNhWvpZEWDsbGm9v1eCQCtPfRki7jd1p", "fee": 1400000, "feeAssetId": null, "timestamp": 1605167571039, "version": 2, "chainId": 84, "sender": "3N5rNyYSAsaP9QL2eQq286RhevB8msHFffu", "senderPublicKey": "CBTEuFN6ku1LNaPuGHHTMh2CBb3kPa5D73XXTJvKydun", "proofs": [ "5ax4Gi7ABDyfarT5Jud5FaRqHYdGDEWFS4iMHHQJyzXYmVA5wuNwsbkFehPPWFPxhXTxGsAemTN6ArKmD2ZpZbGk" ], "script": "base64:AAIDAAAAAAAAACcIARIHCgUICAgICBIECgIICBIDCgEIEgMKAQgSAwoBCBIAEgMKAQEAAAATAAAAAAZ1cFZvdGUCAAAABnVwdm90ZQAAAAANYWRtaW5BZGRyZXNzMQEAAAAaAVQ4tiFYgDZYCD0glAFUKaBkl4Sdk8P2NIsAAAAADWFkbWluQWRkcmVzczIBAAAAGgFU5Y9QPfO/GENOfAQWVCPUAvi8IBb2t+w6AAAAAA1hZG1pbkFkZHJlc3MzAQAAABoBVD6NGwucHiBYhj9yswIcasK4s6nfRDIKFQAAAAAFZHl6SWQBAAAAIH6rQdnOUsq3YY00nk9jVDL2OOQ/e846gXAImq8xTxZrAQAAAA1nZXRQcm9maWxlS2V5AAAAAQAAAAJpZAkAASwAAAACBQAAAAJpZAIAAAAUX2VudHJlcHJlbmV1clByb2ZpbGUBAAAADGdldFN0YXR1c0tleQAAAAEAAAACaWQJAAEsAAAAAgUAAAACaWQCAAAAB19zdGF0dXMBAAAAEWdldFZvdGVyQW1vdW50S2V5AAAAAgAAAAJpZAAAAAZ2b3RlSWQJAAEsAAAAAgkAASwAAAACCQABLAA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lvdSBkb24ndCBoYXZlIGFueSBzdGFrZXMDCQAAZgAAAAIFAAAABmFtb3VudAUAAAAMY3VycmVudFN0YWtlCQAAAgAAAAECAAAAM1lvdSBjYW4ndCB3aXRoZHJhdyBhbiBhbW91bnQgaGlnaGVyIHRoYW4geW91IHN0YWtlZAQAAAAPbmV3U3Rha2VkQW1vdW50CQAAZQAAAAIFAAAADGN1cnJlbnRTdGFrZQUAAAAGYW1vdW50CQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAADGdldFN0YWtlcktleQAAAAEFAAAABnN0YWtlcgUAAAAPbmV3U3Rha2VkQW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABWR5eklkBQAAAANuaWwAAAAA14PZeQ==", "height": 1261866, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: F3Fdv54noSFXLmYRku2G9QF9ktXH6PQaop6nVLY43tby Next: DBo8gern8siwr5h3cZKaV1p9GPuNDkkPEMVQ9rAq7kuf Diff:
Old | New | Differences | |
---|---|---|---|
79 | 79 | then true | |
80 | 80 | else false | |
81 | 81 | } | |
82 | + | ||
83 | + | ||
84 | + | func getStakerKey (staker) = (staker + "_stake") | |
85 | + | ||
86 | + | ||
87 | + | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
88 | + | case a: Int => | |
89 | + | a | |
90 | + | case _ => | |
91 | + | 0 | |
92 | + | } | |
82 | 93 | ||
83 | 94 | ||
84 | 95 | @Callable(i) | |
170 | 181 | } | |
171 | 182 | ||
172 | 183 | ||
184 | + | ||
185 | + | @Callable(i) | |
186 | + | func stake () = { | |
187 | + | let staker = toBase58String(i.caller.bytes) | |
188 | + | let pmt = extract(i.payment) | |
189 | + | if ((pmt.amount == 0)) | |
190 | + | then throw("Stake amount too low") | |
191 | + | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
192 | + | then throw("You can only stake with DYZRUPT token") | |
193 | + | else { | |
194 | + | let currentStake = getCurrentStake(staker) | |
195 | + | let stakePercent = (20 / 100) | |
196 | + | let stakeableAmount = (pmt.amount * stakePercent) | |
197 | + | let amountToStake = (pmt.amount - stakeableAmount) | |
198 | + | let newStakedAmount = (currentStake + amountToStake) | |
199 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
200 | + | } | |
201 | + | } | |
202 | + | ||
203 | + | ||
204 | + | ||
205 | + | @Callable(i) | |
206 | + | func unstake (amount) = { | |
207 | + | let staker = toBase58String(i.caller.bytes) | |
208 | + | let currentStake = getCurrentStake(staker) | |
209 | + | if ((currentStake == 0)) | |
210 | + | then throw("You don't have any stakes") | |
211 | + | else if ((amount > currentStake)) | |
212 | + | then throw("You can't withdraw an amount higher than you staked") | |
213 | + | else { | |
214 | + | let newStakedAmount = (currentStake - amount) | |
215 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(i.caller, amount, dyzId)])) | |
216 | + | } | |
217 | + | } | |
218 | + | ||
219 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let upVote = "upvote" | |
5 | 5 | ||
6 | 6 | let adminAddress1 = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC' | |
7 | 7 | ||
8 | 8 | let adminAddress2 = base58'3NAqtCScgFynCuRLUoXm2BHTdu8suatCe7b' | |
9 | 9 | ||
10 | 10 | let adminAddress3 = base58'3Mucpi1K4FMVrZKnYEgjxQf5DkkBX7QrHoJ' | |
11 | 11 | ||
12 | 12 | let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G' | |
13 | 13 | ||
14 | 14 | func getProfileKey (id) = (id + "_entrepreneurProfile") | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStatusKey (id) = (id + "_status") | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount") | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getVoteKey (id,type) = if ((type == "upvote")) | |
24 | 24 | then (id + "_upvote") | |
25 | 25 | else throw("Invalid vote type") | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getVoteAmountKey (id,type) = if ((type == "upvote")) | |
29 | 29 | then (((id + "_") + type) + "_amount") | |
30 | 30 | else throw("Invalid vote type") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func profileExist (id) = match getString(this, getProfileKey(id)) { | |
34 | 34 | case a: String => | |
35 | 35 | true | |
36 | 36 | case _ => | |
37 | 37 | false | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) { | |
42 | 42 | case a: String => | |
43 | 43 | a | |
44 | 44 | case _ => | |
45 | 45 | false | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) { | |
50 | 50 | case a: Int => | |
51 | 51 | a | |
52 | 52 | case _ => | |
53 | 53 | throw("Not a valid vote ID") | |
54 | 54 | } | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getVoteAmountCount (voteId,vote) = match getInteger(this, getVoteAmountKey(voteId, vote)) { | |
58 | 58 | case a: Int => | |
59 | 59 | a | |
60 | 60 | case _ => | |
61 | 61 | 0 | |
62 | 62 | } | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote") | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) { | |
69 | 69 | case a: String => | |
70 | 70 | a | |
71 | 71 | case _ => | |
72 | 72 | "" | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func canVote (address,voteId) = { | |
77 | 77 | let voter = getVoter(address, voteId) | |
78 | 78 | if ((voter == "")) | |
79 | 79 | then true | |
80 | 80 | else false | |
81 | 81 | } | |
82 | + | ||
83 | + | ||
84 | + | func getStakerKey (staker) = (staker + "_stake") | |
85 | + | ||
86 | + | ||
87 | + | func getCurrentStake (staker) = match getInteger(this, getStakerKey(staker)) { | |
88 | + | case a: Int => | |
89 | + | a | |
90 | + | case _ => | |
91 | + | 0 | |
92 | + | } | |
82 | 93 | ||
83 | 94 | ||
84 | 95 | @Callable(i) | |
85 | 96 | func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes == adminAddress1)) | |
86 | 97 | then true | |
87 | 98 | else (i.caller.bytes == adminAddress2)) | |
88 | 99 | then true | |
89 | 100 | else (i.caller.bytes == adminAddress3)) | |
90 | 101 | then { | |
91 | 102 | let transactionId = toBase58String(i.transactionId) | |
92 | 103 | WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getVoteAmountKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")]) | |
93 | 104 | } | |
94 | 105 | else throw("Only Dyzrupt Admin can call this dApp function") | |
95 | 106 | ||
96 | 107 | ||
97 | 108 | ||
98 | 109 | @Callable(i) | |
99 | 110 | func vote (voteId,vote) = { | |
100 | 111 | let pmt = extract(i.payment) | |
101 | 112 | let voter = toBase58String(i.caller.bytes) | |
102 | 113 | if ((pmt.amount == 0)) | |
103 | 114 | then throw("You cannot vote without paying voting fee") | |
104 | 115 | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
105 | 116 | then throw("You can only vote with DYZRUPT token") | |
106 | 117 | else if (canVote(voter, voteId)) | |
107 | 118 | then if (profileExist(voteId)) | |
108 | 119 | then if ((getVoteStatus(voteId) == "open")) | |
109 | 120 | then if ((vote == upVote)) | |
110 | 121 | then { | |
111 | 122 | let voteCount = getVoteCount(voteId, vote) | |
112 | 123 | let voteAmountCount = getVoteAmountCount(voteId, vote) | |
113 | 124 | let newVoteCount = (voteCount + 1) | |
114 | 125 | let newVoteAmountCount = (voteAmountCount + pmt.amount) | |
115 | 126 | ScriptResult(WriteSet([DataEntry(getVoteKey(voteId, vote), newVoteCount), DataEntry(getVoterKey(voter, voteId), voteId), DataEntry(getVoterAmountKey(voter, voteId), pmt.amount), DataEntry(getVoteAmountKey(voteId, vote), newVoteAmountCount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
116 | 127 | } | |
117 | 128 | else throw("Not a valid vote value") | |
118 | 129 | else throw("This profile is not open for voting") | |
119 | 130 | else throw("Invalid Profile") | |
120 | 131 | else throw("You can't vote twice") | |
121 | 132 | } | |
122 | 133 | ||
123 | 134 | ||
124 | 135 | ||
125 | 136 | @Callable(i) | |
126 | 137 | func openVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
127 | 138 | then true | |
128 | 139 | else (i.caller.bytes == adminAddress2)) | |
129 | 140 | then true | |
130 | 141 | else (i.caller.bytes == adminAddress3)) | |
131 | 142 | then if (profileExist(voteId)) | |
132 | 143 | then WriteSet([DataEntry(getStatusKey(voteId), "open")]) | |
133 | 144 | else throw("Invalid ID") | |
134 | 145 | else throw("Only Dyzrupt Admin can call this dApp function") | |
135 | 146 | ||
136 | 147 | ||
137 | 148 | ||
138 | 149 | @Callable(i) | |
139 | 150 | func closeVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1)) | |
140 | 151 | then true | |
141 | 152 | else (i.caller.bytes == adminAddress2)) | |
142 | 153 | then true | |
143 | 154 | else (i.caller.bytes == adminAddress3)) | |
144 | 155 | then if (profileExist(voteId)) | |
145 | 156 | then WriteSet([DataEntry(getStatusKey(voteId), "closed")]) | |
146 | 157 | else throw("Invalid ID") | |
147 | 158 | else throw("Only Dyzrupt Admin can call this dApp function") | |
148 | 159 | ||
149 | 160 | ||
150 | 161 | ||
151 | 162 | @Callable(i) | |
152 | 163 | func withdraw (voteId) = { | |
153 | 164 | let voter = toBase58String(i.caller.bytes) | |
154 | 165 | if ((getVoter(voter, voteId) != "")) | |
155 | 166 | then if ((getVoteStatus(voteId) == "closed")) | |
156 | 167 | then { | |
157 | 168 | let currentKey = getVoterAmountKey(voter, voteId) | |
158 | 169 | let currentAmount = match getInteger(this, currentKey) { | |
159 | 170 | case a: Int => | |
160 | 171 | a | |
161 | 172 | case _ => | |
162 | 173 | throw("You didn't vote for this entrepreneur") | |
163 | 174 | } | |
164 | 175 | if ((currentAmount == 0)) | |
165 | 176 | then throw("Seems you have previously withdrawn.") | |
166 | 177 | else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)])) | |
167 | 178 | } | |
168 | 179 | else throw("Can't withdraw vote amount while voting is still open.") | |
169 | 180 | else throw("You didn't vote for this entrepreneur") | |
170 | 181 | } | |
171 | 182 | ||
172 | 183 | ||
184 | + | ||
185 | + | @Callable(i) | |
186 | + | func stake () = { | |
187 | + | let staker = toBase58String(i.caller.bytes) | |
188 | + | let pmt = extract(i.payment) | |
189 | + | if ((pmt.amount == 0)) | |
190 | + | then throw("Stake amount too low") | |
191 | + | else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G')) | |
192 | + | then throw("You can only stake with DYZRUPT token") | |
193 | + | else { | |
194 | + | let currentStake = getCurrentStake(staker) | |
195 | + | let stakePercent = (20 / 100) | |
196 | + | let stakeableAmount = (pmt.amount * stakePercent) | |
197 | + | let amountToStake = (pmt.amount - stakeableAmount) | |
198 | + | let newStakedAmount = (currentStake + amountToStake) | |
199 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(this, pmt.amount, dyzId)])) | |
200 | + | } | |
201 | + | } | |
202 | + | ||
203 | + | ||
204 | + | ||
205 | + | @Callable(i) | |
206 | + | func unstake (amount) = { | |
207 | + | let staker = toBase58String(i.caller.bytes) | |
208 | + | let currentStake = getCurrentStake(staker) | |
209 | + | if ((currentStake == 0)) | |
210 | + | then throw("You don't have any stakes") | |
211 | + | else if ((amount > currentStake)) | |
212 | + | then throw("You can't withdraw an amount higher than you staked") | |
213 | + | else { | |
214 | + | let newStakedAmount = (currentStake - amount) | |
215 | + | ScriptResult(WriteSet([DataEntry(getStakerKey(staker), newStakedAmount)]), TransferSet([ScriptTransfer(i.caller, amount, dyzId)])) | |
216 | + | } | |
217 | + | } | |
218 | + | ||
219 | + |
github/deemru/w8io/026f985 32.62 ms ◑