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/e846gXAImq8xTxZrAQAAAA1nZXRQcm9maWxlS2V5AAAAAQAAAAJpZAkAASwAAAACBQAAAAJpZAIAAAAUX2VudHJlcHJlbmV1clByb2ZpbGUBAAAADGdldFN0YXR1c0tleQAAAAEAAAACaWQJAAEsAAAAAgUAAAACaWQCAAAAB19zdGF0dXMBAAAAEWdldFZvdGVyQW1vdW50S2V5AAAAAgAAAAJpZAAAAAZ2b3RlSWQJAAEsAAAAAgkAASwAAAACCQABLA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VlvdSBkb24ndCBoYXZlIGFueSBzdGFrZXMDCQAAZgAAAAIFAAAABmFtb3VudAUAAAAMY3VycmVudFN0YWtlCQAAAgAAAAECAAAAM1lvdSBjYW4ndCB3aXRoZHJhdyBhbiBhbW91bnQgaGlnaGVyIHRoYW4geW91IHN0YWtlZAQAAAAPbmV3U3Rha2VkQW1vdW50CQAAZQAAAAIFAAAADGN1cnJlbnRTdGFrZQUAAAAGYW1vdW50CQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAADGdldFN0YWtlcktleQAAAAEFAAAABnN0YWtlcgUAAAAPbmV3U3Rha2VkQW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABWR5eklkBQAAAANuaWwAAAAA14PZeQ==", "height": 1261866, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: F3Fdv54noSFXLmYRku2G9QF9ktXH6PQaop6nVLY43tby Next: DBo8gern8siwr5h3cZKaV1p9GPuNDkkPEMVQ9rAq7kuf Diff:
OldNewDifferences
7979 then true
8080 else false
8181 }
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+}
8293
8394
8495 @Callable(i)
170181 }
171182
172183
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+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let upVote = "upvote"
55
66 let adminAddress1 = base58'3Mu5woJ54s7vHJgaeNcJ4C9ByfdmMF2jpjC'
77
88 let adminAddress2 = base58'3NAqtCScgFynCuRLUoXm2BHTdu8suatCe7b'
99
1010 let adminAddress3 = base58'3Mucpi1K4FMVrZKnYEgjxQf5DkkBX7QrHoJ'
1111
1212 let dyzId = base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G'
1313
1414 func getProfileKey (id) = (id + "_entrepreneurProfile")
1515
1616
1717 func getStatusKey (id) = (id + "_status")
1818
1919
2020 func getVoterAmountKey (id,voteId) = (((id + "_") + voteId) + "_amount")
2121
2222
2323 func getVoteKey (id,type) = if ((type == "upvote"))
2424 then (id + "_upvote")
2525 else throw("Invalid vote type")
2626
2727
2828 func getVoteAmountKey (id,type) = if ((type == "upvote"))
2929 then (((id + "_") + type) + "_amount")
3030 else throw("Invalid vote type")
3131
3232
3333 func profileExist (id) = match getString(this, getProfileKey(id)) {
3434 case a: String =>
3535 true
3636 case _ =>
3737 false
3838 }
3939
4040
4141 func getVoteStatus (voteId) = match getString(this, getStatusKey(voteId)) {
4242 case a: String =>
4343 a
4444 case _ =>
4545 false
4646 }
4747
4848
4949 func getVoteCount (voteId,vote) = match getInteger(this, getVoteKey(voteId, vote)) {
5050 case a: Int =>
5151 a
5252 case _ =>
5353 throw("Not a valid vote ID")
5454 }
5555
5656
5757 func getVoteAmountCount (voteId,vote) = match getInteger(this, getVoteAmountKey(voteId, vote)) {
5858 case a: Int =>
5959 a
6060 case _ =>
6161 0
6262 }
6363
6464
6565 func getVoterKey (address,voteId) = ((((address + "_") + voteId) + "_") + "vote")
6666
6767
6868 func getVoter (address,voteId) = match getString(this, getVoterKey(address, voteId)) {
6969 case a: String =>
7070 a
7171 case _ =>
7272 ""
7373 }
7474
7575
7676 func canVote (address,voteId) = {
7777 let voter = getVoter(address, voteId)
7878 if ((voter == ""))
7979 then true
8080 else false
8181 }
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+}
8293
8394
8495 @Callable(i)
8596 func addEntrepreneurProfile (name,avatar,bio,gender,location) = if (if (if ((i.caller.bytes == adminAddress1))
8697 then true
8798 else (i.caller.bytes == adminAddress2))
8899 then true
89100 else (i.caller.bytes == adminAddress3))
90101 then {
91102 let transactionId = toBase58String(i.transactionId)
92103 WriteSet([DataEntry(getProfileKey(transactionId), ((((((((name + "_") + avatar) + "_") + bio) + "_") + gender) + "_") + location)), DataEntry(getVoteKey(transactionId, "upvote"), 0), DataEntry(getVoteAmountKey(transactionId, "upvote"), 0), DataEntry(getStatusKey(transactionId), "open")])
93104 }
94105 else throw("Only Dyzrupt Admin can call this dApp function")
95106
96107
97108
98109 @Callable(i)
99110 func vote (voteId,vote) = {
100111 let pmt = extract(i.payment)
101112 let voter = toBase58String(i.caller.bytes)
102113 if ((pmt.amount == 0))
103114 then throw("You cannot vote without paying voting fee")
104115 else if ((pmt.assetId != base58'9XTqBQeJvdMs8VNHv6rXiJLJichg2acG7wCfYcTajQ1G'))
105116 then throw("You can only vote with DYZRUPT token")
106117 else if (canVote(voter, voteId))
107118 then if (profileExist(voteId))
108119 then if ((getVoteStatus(voteId) == "open"))
109120 then if ((vote == upVote))
110121 then {
111122 let voteCount = getVoteCount(voteId, vote)
112123 let voteAmountCount = getVoteAmountCount(voteId, vote)
113124 let newVoteCount = (voteCount + 1)
114125 let newVoteAmountCount = (voteAmountCount + pmt.amount)
115126 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)]))
116127 }
117128 else throw("Not a valid vote value")
118129 else throw("This profile is not open for voting")
119130 else throw("Invalid Profile")
120131 else throw("You can't vote twice")
121132 }
122133
123134
124135
125136 @Callable(i)
126137 func openVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1))
127138 then true
128139 else (i.caller.bytes == adminAddress2))
129140 then true
130141 else (i.caller.bytes == adminAddress3))
131142 then if (profileExist(voteId))
132143 then WriteSet([DataEntry(getStatusKey(voteId), "open")])
133144 else throw("Invalid ID")
134145 else throw("Only Dyzrupt Admin can call this dApp function")
135146
136147
137148
138149 @Callable(i)
139150 func closeVote (voteId) = if (if (if ((i.caller.bytes == adminAddress1))
140151 then true
141152 else (i.caller.bytes == adminAddress2))
142153 then true
143154 else (i.caller.bytes == adminAddress3))
144155 then if (profileExist(voteId))
145156 then WriteSet([DataEntry(getStatusKey(voteId), "closed")])
146157 else throw("Invalid ID")
147158 else throw("Only Dyzrupt Admin can call this dApp function")
148159
149160
150161
151162 @Callable(i)
152163 func withdraw (voteId) = {
153164 let voter = toBase58String(i.caller.bytes)
154165 if ((getVoter(voter, voteId) != ""))
155166 then if ((getVoteStatus(voteId) == "closed"))
156167 then {
157168 let currentKey = getVoterAmountKey(voter, voteId)
158169 let currentAmount = match getInteger(this, currentKey) {
159170 case a: Int =>
160171 a
161172 case _ =>
162173 throw("You didn't vote for this entrepreneur")
163174 }
164175 if ((currentAmount == 0))
165176 then throw("Seems you have previously withdrawn.")
166177 else ScriptResult(WriteSet([DataEntry(currentKey, 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, dyzId)]))
167178 }
168179 else throw("Can't withdraw vote amount while voting is still open.")
169180 else throw("You didn't vote for this entrepreneur")
170181 }
171182
172183
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