tx · CaB2brN55ht5syni96FeETsQWaiHSuaATf8QAHSe3fV1

3PKNvmzTFYkwRDVJUFY2WxZyJ8D2GC2GP2u:  -0.01400000 Waves

2021.10.03 23:28 [2795521] smart account 3PKNvmzTFYkwRDVJUFY2WxZyJ8D2GC2GP2u > SELF 0.00000000 Waves

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

github/deemru/w8io/6500d08 
31.79 ms