tx · 9bvdqNr3rreeKWQiWhT9sZ3nJERdaUAaPqBF9PrKZsxD 3N2uKeePNFjWTA1HgzWDRC1DTENWkn1S9ct: -0.03099000 Waves 2020.10.18 20:49 [1226336] smart account 3N2uKeePNFjWTA1HgzWDRC1DTENWkn1S9ct > SELF 0.00000000 Waves
{ "type": 13, "id": "9bvdqNr3rreeKWQiWhT9sZ3nJERdaUAaPqBF9PrKZsxD", "fee": 3099000, "feeAssetId": null, "timestamp": 1603043384819, "version": 2, "chainId": 84, "sender": "3N2uKeePNFjWTA1HgzWDRC1DTENWkn1S9ct", "senderPublicKey": "2Zu93Nn4XQDQJh61td98RYfNB44AtMrZeguWMuNBS41n", "proofs": [ "24HD5KTMyFkmgVWsiVi6Hsk9kSy3LB4We9mDVQ92VQuuEoA69UHhnHP5jvvFzk8P9CwMYJBkNUcsVx4KDguNyuwk" ], "script": "base64:AAIDAAAAAAAAAA8IARIAEgASABIDCgEBEgAAAAAAAAAABQAAAAFpAQAAAAhwYXlZaWVsZAAAAAAEAAAAC0dvdmVyblRva2VuAQAAACC8BnLNTH75zY/85pKTg3cOi9DRRgrZqRPS5vvLPGg8zQQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAMJAABmAAAAAgUAAAANY3VycmVudEFtb3VudAAAAAAAAAAAAAQAAAARR292ZXJuVG9rZW5BbW91bnQJAAPrAAAAAgUAAAAEdGhpcwUAAAALR292ZXJuVG9rZW4DCQAAZgAAAAIAAAAAAAAAAAEFAAAAEUdvdmVyblRva2VuQW1vdW50CQAAAgAAAAECAAAAIU5vIGVub3VnaCBHb3Zlcm5Ub2tlbiBJbiBD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AAAAAAAAAEFAAAAFVVzZXJTdGFrZWRUb2tlbkFtb3VudAkAAAIAAAABCQABLAAAAAICAAAAUllvdSBoYXZlIHRvIFN0YWtlIFN0YWtlZFRva2VuIHRvIGNsYWltIHJld2FyZCAKIFlvdXIgQmFsYW5jZSBvZiBTdGFrZWQgVG9rZW5zIGlzOiAJAAGkAAAAAQUAAAAVVXNlclN0YWtlZFRva2VuQW1vdW50AwkAAGYAAAACBQAAABVVc2VyR292ZXJuVG9rZW5BbW91bnQAAAAAAAAAAGQJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAt3aW5uZXJQcml6ZQUAAAALUHJpemVBbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAEkZ1bmRCb3hTdGFrZWRUb2tlbgAAAAAAAAAAAAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAASVXNlckdvdmVyblRva2VuS2V5AAAAAAAAAABkBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAKd2luQWRkcmVzcwUAAAALUHJpemVBbW91bnQFAAAAC1N0YWtlZFRva2VuCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgAAAAAAAAAAZAUAAAALR292ZXJuVG9rZW4FAAAAA25pbAkAAAIAAAABCQABLAAAAAICAAAAR1lvdSBoYXZlIHRvIGRlcG9zaXQgMTAwIEdvdmVyblRva2VuIHRvIGNsYWltIFJld2FyZCAKIFlvdXIgQmFsYW5jZSBpczogCQABpAAAAAEFAAAAFVVzZXJHb3Zlcm5Ub2tlbkFtb3VudAAAAABNZL4k", "height": 1226336, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9JWc5bPYti7fVHKssj7EFgpDHLxJWJ3ZoSHXHK6uwz5R Next: 8QoFcm59vvwitxgktTLNW6G8nhV2aNB6okdNsr7jSyxH Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | @Callable(i) | |
56 | 56 | func PayToken () = { | |
57 | 57 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
58 | + | let GovernTokenMaxDeposit = toBase58String(GovernToken) | |
58 | 59 | let pmt = extract(i.payment) | |
59 | 60 | if (if (isDefined(pmt.assetId)) | |
60 | 61 | then (extract(pmt.assetId) == GovernToken) | |
67 | 68 | case _ => | |
68 | 69 | 0 | |
69 | 70 | } | |
70 | - | let newAmount = (currentAmount + pmt.amount) | |
71 | - | let GovernTokenAmount = assetBalance(this, GovernToken) | |
72 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
71 | + | let CurrrentGovernTokenDeposit = (currentAmount + pmt.amount) | |
72 | + | let GovernTokenContractBalance = assetBalance(this, GovernToken) | |
73 | + | let GovernTokeMaxDeposited = match getInteger(Address(GovernToken), GovernTokenMaxDeposit) { | |
74 | + | case a: Int => | |
75 | + | a | |
76 | + | case _ => | |
77 | + | 0 | |
78 | + | } | |
79 | + | if ((CurrrentGovernTokenDeposit > GovernTokeMaxDeposited)) | |
80 | + | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit)]) | |
81 | + | else throw(((("Your Balance of GovernToken is " + toString(CurrrentGovernTokenDeposit)) + " But Max GovernToken is: ") + toString(GovernTokeMaxDeposited))) | |
73 | 82 | } | |
74 | 83 | else throw("Can deposit only Govern Token") | |
75 | 84 | } | |
135 | 144 | if ((PrizeAmount == 0)) | |
136 | 145 | then throw("No prize to Claim") | |
137 | 146 | else if ((UserStakedToken != winnerPrize)) | |
138 | - | then throw | |
147 | + | then throw("You are not the winner hence cannot claim the reward ") | |
139 | 148 | else if ((1 > UserStakedTokenAmount)) | |
140 | - | then throw("You have to Stake StakedToken to claim reward") | |
149 | + | then throw(("You have to Stake StakedToken to claim reward | |
150 | + | Your Balance of Staked Tokens is: " + toString(UserStakedTokenAmount))) | |
141 | 151 | else if ((UserGovernTokenAmount > 100)) | |
142 | 152 | then ScriptResult(WriteSet([DataEntry(winnerPrize, PrizeAmount), DataEntry(FundBoxStakedToken, 0), DataEntry(UserGovernTokenKey, 100)]), TransferSet([ScriptTransfer(winAddress, PrizeAmount, StakedToken), ScriptTransfer(i.caller, 100, GovernToken)])) | |
143 | - | else throw("You have to deposit 100 GovernToken to claim Reward") | |
153 | + | else throw(("You have to deposit 100 GovernToken to claim Reward | |
154 | + | Your Balance is: " + toString(UserGovernTokenAmount))) | |
144 | 155 | } | |
145 | 156 | ||
146 | 157 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func payYield () = { | |
8 | 8 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
9 | 9 | let currentKey = toBase58String(i.caller.bytes) | |
10 | 10 | let currentAmount = match getInteger(this, currentKey) { | |
11 | 11 | case a: Int => | |
12 | 12 | a | |
13 | 13 | case _ => | |
14 | 14 | 0 | |
15 | 15 | } | |
16 | 16 | if ((currentAmount > 0)) | |
17 | 17 | then { | |
18 | 18 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
19 | 19 | if ((1 > GovernTokenAmount)) | |
20 | 20 | then throw("No enough GovernToken In Contract") | |
21 | 21 | else ScriptResult(WriteSet([DataEntry(currentKey, 10)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken)])) | |
22 | 22 | } | |
23 | 23 | else throw("You need to deposit Collateral Token to receive Govern Token") | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | 28 | @Callable(i) | |
29 | 29 | func Stake () = { | |
30 | 30 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
31 | 31 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
32 | 32 | let pmt = extract(i.payment) | |
33 | 33 | if (if (isDefined(pmt.assetId)) | |
34 | 34 | then (extract(pmt.assetId) == CollateralToken) | |
35 | 35 | else false) | |
36 | 36 | then { | |
37 | 37 | let currentKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(CollateralToken)) | |
38 | 38 | let currentAmount = match getInteger(this, currentKey) { | |
39 | 39 | case a: Int => | |
40 | 40 | a | |
41 | 41 | case _ => | |
42 | 42 | 0 | |
43 | 43 | } | |
44 | 44 | let newAmount = (currentAmount + pmt.amount) | |
45 | 45 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
46 | 46 | if ((1 > GovernTokenAmount)) | |
47 | 47 | then throw("No enough GovernToken In Contract") | |
48 | 48 | else ScriptResult(WriteSet([DataEntry(currentKey, 10), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
49 | 49 | } | |
50 | 50 | else throw("Can deposit only MyToken") | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | 56 | func PayToken () = { | |
57 | 57 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
58 | + | let GovernTokenMaxDeposit = toBase58String(GovernToken) | |
58 | 59 | let pmt = extract(i.payment) | |
59 | 60 | if (if (isDefined(pmt.assetId)) | |
60 | 61 | then (extract(pmt.assetId) == GovernToken) | |
61 | 62 | else false) | |
62 | 63 | then { | |
63 | 64 | let currentKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
64 | 65 | let currentAmount = match getInteger(this, currentKey) { | |
65 | 66 | case a: Int => | |
66 | 67 | a | |
67 | 68 | case _ => | |
68 | 69 | 0 | |
69 | 70 | } | |
70 | - | let newAmount = (currentAmount + pmt.amount) | |
71 | - | let GovernTokenAmount = assetBalance(this, GovernToken) | |
72 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
71 | + | let CurrrentGovernTokenDeposit = (currentAmount + pmt.amount) | |
72 | + | let GovernTokenContractBalance = assetBalance(this, GovernToken) | |
73 | + | let GovernTokeMaxDeposited = match getInteger(Address(GovernToken), GovernTokenMaxDeposit) { | |
74 | + | case a: Int => | |
75 | + | a | |
76 | + | case _ => | |
77 | + | 0 | |
78 | + | } | |
79 | + | if ((CurrrentGovernTokenDeposit > GovernTokeMaxDeposited)) | |
80 | + | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit)]) | |
81 | + | else throw(((("Your Balance of GovernToken is " + toString(CurrrentGovernTokenDeposit)) + " But Max GovernToken is: ") + toString(GovernTokeMaxDeposited))) | |
73 | 82 | } | |
74 | 83 | else throw("Can deposit only Govern Token") | |
75 | 84 | } | |
76 | 85 | ||
77 | 86 | ||
78 | 87 | ||
79 | 88 | @Callable(i) | |
80 | 89 | func withdrawFunds (amount) = { | |
81 | 90 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
82 | 91 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
83 | 92 | let currentKey = toBase58String(i.caller.bytes) | |
84 | 93 | let currentAmount = match getInteger(this, currentKey) { | |
85 | 94 | case a: Int => | |
86 | 95 | a | |
87 | 96 | case _ => | |
88 | 97 | 0 | |
89 | 98 | } | |
90 | 99 | let newAmount = (currentAmount - amount) | |
91 | 100 | if ((0 > amount)) | |
92 | 101 | then throw("Can't withdraw negative amount") | |
93 | 102 | else if ((0 > newAmount)) | |
94 | 103 | then throw("User cannot withdraw more than deposited funds") | |
95 | 104 | else { | |
96 | 105 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
97 | 106 | if ((1 > GovernTokenAmount)) | |
98 | 107 | then throw("No enough GovernToken In Contract") | |
99 | 108 | else ScriptResult(WriteSet([DataEntry(currentKey, 1), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken), ScriptTransfer(i.caller, amount, CollateralToken)])) | |
100 | 109 | } | |
101 | 110 | } | |
102 | 111 | ||
103 | 112 | ||
104 | 113 | ||
105 | 114 | @Callable(i) | |
106 | 115 | func ClaimPrize () = { | |
107 | 116 | let StakedToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
108 | 117 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
109 | 118 | let FundBoxAddress58 = base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD' | |
110 | 119 | let winnerPrize = (("3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA" + "_") + toBase58String(StakedToken)) | |
111 | 120 | let winAddress = Address(base58'3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA') | |
112 | 121 | let FundBoxAddress = Address(base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD') | |
113 | 122 | let FundBox = "3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD" | |
114 | 123 | let UserGovernTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
115 | 124 | let UserStakedToken = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
116 | 125 | let FundBoxStakedToken = ((toBase58String(FundBoxAddress58) + "_") + toBase58String(StakedToken)) | |
117 | 126 | let UserGovernTokenAmount = match getInteger(this, UserGovernTokenKey) { | |
118 | 127 | case a: Int => | |
119 | 128 | a | |
120 | 129 | case _ => | |
121 | 130 | 0 | |
122 | 131 | } | |
123 | 132 | let UserStakedTokenAmount = match getInteger(this, UserStakedToken) { | |
124 | 133 | case a: Int => | |
125 | 134 | a | |
126 | 135 | case _ => | |
127 | 136 | 0 | |
128 | 137 | } | |
129 | 138 | let PrizeAmount = match getInteger(this, FundBoxStakedToken) { | |
130 | 139 | case a: Int => | |
131 | 140 | a | |
132 | 141 | case _ => | |
133 | 142 | 0 | |
134 | 143 | } | |
135 | 144 | if ((PrizeAmount == 0)) | |
136 | 145 | then throw("No prize to Claim") | |
137 | 146 | else if ((UserStakedToken != winnerPrize)) | |
138 | - | then throw | |
147 | + | then throw("You are not the winner hence cannot claim the reward ") | |
139 | 148 | else if ((1 > UserStakedTokenAmount)) | |
140 | - | then throw("You have to Stake StakedToken to claim reward") | |
149 | + | then throw(("You have to Stake StakedToken to claim reward | |
150 | + | Your Balance of Staked Tokens is: " + toString(UserStakedTokenAmount))) | |
141 | 151 | else if ((UserGovernTokenAmount > 100)) | |
142 | 152 | then ScriptResult(WriteSet([DataEntry(winnerPrize, PrizeAmount), DataEntry(FundBoxStakedToken, 0), DataEntry(UserGovernTokenKey, 100)]), TransferSet([ScriptTransfer(winAddress, PrizeAmount, StakedToken), ScriptTransfer(i.caller, 100, GovernToken)])) | |
143 | - | else throw("You have to deposit 100 GovernToken to claim Reward") | |
153 | + | else throw(("You have to deposit 100 GovernToken to claim Reward | |
154 | + | Your Balance is: " + toString(UserGovernTokenAmount))) | |
144 | 155 | } | |
145 | 156 | ||
146 | 157 |
github/deemru/w8io/169f3d6 47.40 ms ◑