tx · 98qwy8xkVB7dJTse35imB5KrzHTdnA3qRckXv8CniVED

3PKNvmzTFYkwRDVJUFY2WxZyJ8D2GC2GP2u:  -0.01400000 Waves

2022.06.22 17:23 [3173339] smart account 3PKNvmzTFYkwRDVJUFY2WxZyJ8D2GC2GP2u > SELF 0.00000000 Waves

{ "type": 13, "id": "98qwy8xkVB7dJTse35imB5KrzHTdnA3qRckXv8CniVED", "fee": 1400000, "feeAssetId": null, "timestamp": 1655907785788, "version": 1, "sender": "3PKNvmzTFYkwRDVJUFY2WxZyJ8D2GC2GP2u", "senderPublicKey": "8mrUL4yzR4vz145JJYrAb9Q28r83vV9CxxSfRk4UeWFY", "proofs": [ "22rrWXpmgzwEcDDaEWSujK8pz9AWsQZXjKAxiHADmnP7SwXA9scGzPPWDvxf6bM9VKpZ5b7UoV8LhsKSoRJ2kHke" ], "script": null, "chainId": 87, "height": 3173339, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FGbAHFbaAPAg2SxvxonPmxZR6S2N9wwcXzMhYggzV3t6 Next: none Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let froeAssetId = base58'A4h9aifPtz371noBA1Khi2Eb4L3Vzf8LC8PtF4QysEd9'
5-
6-let baseUnit = 10000
7-
8-let totalVoters = match getInteger("Total_Voters") {
9- case vi: Int =>
10- vi
11- case _ =>
12- 0
13-}
14-
15-let totalBalance = match getInteger("Total_Balance") {
16- case tBal: Int =>
17- tBal
18- case _ =>
19- 0
20-}
21-
22-let grandTotal = if ((totalVoters != 0))
23- then totalVoters
24- else throw("Total Number of Voters is Undefined")
25-
26-let workingBal = if ((totalBalance != 0))
27- then (totalBalance * baseUnit)
28- else throw("Available Total Balance have not been specified")
29-
30-func calculateReward (percentage) = {
31- let converteredPercentage = (percentage * baseUnit)
32- let percentageReward = fraction(workingBal, converteredPercentage, (100 * baseUnit))
33- let reward = (percentageReward / grandTotal)
34- reward
35- }
36-
37-
38-@Callable(i)
39-func Vote () = {
40- let pmt = if ((size(i.payments) == 1))
41- then i.payments[0]
42- else throw("You need exactly one froe to make a vote")
43- let AddressOfVoter = toBase58String(i.caller.bytes)
44- let currentvalue = match getInteger(this, "Total_vote_amount") {
45- case t: Int =>
46- t
47- case _ =>
48- 0
49- }
50- let checkVoter = match getInteger(this, ("Vote_Amount_For_" + AddressOfVoter)) {
51- case c: Int =>
52- c
53- case _ =>
54- unit
55- }
56- let votersIndex = match getInteger(this, "Voter_Index") {
57- case a: Int =>
58- a
59- case _ =>
60- 0
61- }
62- let voteState = match getString(this, "Vote_State") {
63- case v: String =>
64- v
65- case _ =>
66- unit
67- }
68- if ((pmt.assetId != froeAssetId))
69- then throw((("Incorrect asset attached, please attach " + toBase58String(froeAssetId)) + " only."))
70- else if ((voteState == "DISABLED"))
71- then throw("Voting is currently disable")
72- else if ((checkVoter != unit))
73- then throw("You already Voted")
74- else if ((10000 != pmt.amount))
75- then throw("Exactly 1 Froe is need to make a vote")
76- else [StringEntry("Voter", AddressOfVoter), IntegerEntry(("Vote_Amount_For_" + AddressOfVoter), pmt.amount), IntegerEntry("Voter_Index", (votersIndex + 1))]
77- }
78-
79-
80-
81-@Callable(i)
82-func Withdraw () = {
83- let checkWithDrawState = getStringValue(this, "Withdraw_State")
84- let eligibleReward = getBooleanValue(this, "Vote_Successful")
85- let AddressOfVoter = toBase58String(i.caller.bytes)
86- let reward = if ((eligibleReward == true))
87- then calculateReward(81)
88- else baseUnit
89- let checkValidVote = match getInteger(this, ("Vote_Amount_For_" + AddressOfVoter)) {
90- case val: Int =>
91- val
92- case _ =>
93- 0
94- }
95- let alreadyWithdrawn = match getString(this, "Marked_Withdrawn") {
96- case t: String =>
97- t
98- case _ =>
99- unit
100- }
101- if ((checkWithDrawState == "DISABLED"))
102- then throw("Withdrawal Is currently disabled. A minimum of 30 Days is needed for eligible withdrawals")
103- else if ((checkValidVote == 0))
104- then throw("No Valid Vote Found")
105- else if ((alreadyWithdrawn != unit))
106- then throw("You already withdrew")
107- else [ScriptTransfer(i.caller, reward, froeAssetId), IntegerEntry("Reward_Due_Voter", reward), StringEntry("Marked_Withdrawn", AddressOfVoter)]
108- }
109-
110-
111-@Verifier(tx)
112-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
113-
1+# no script

github/deemru/w8io/6500d08 
38.47 ms