tx · 2dr36NNg3enjc7r9dj1x4jH3pFVR6Q7HpWnnCFKUnBPE 3N3en9HRhzbk3DDqeGd6DUKc1SG4rmpXguH: -0.09990000 Waves 2020.10.17 20:50 [1224890] smart account 3N3en9HRhzbk3DDqeGd6DUKc1SG4rmpXguH > SELF 0.00000000 Waves
{ "type": 13, "id": "2dr36NNg3enjc7r9dj1x4jH3pFVR6Q7HpWnnCFKUnBPE", "fee": 9990000, "feeAssetId": null, "timestamp": 1602957025247, "version": 2, "chainId": 84, "sender": "3N3en9HRhzbk3DDqeGd6DUKc1SG4rmpXguH", "senderPublicKey": "3UC2eCnSLx9fHcXvssZJZLNzMshb9NM6GchfmEhx6syQ", "proofs": [ "3hsdN1Eg9HUbsVdhpewT4S47VZwzRAdKR35KKMMNbw9USkNyCXtxUs7UAGM3HuuM9NxigBXh8agPy4cNBHS8Q6fF" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAAAAAAAAQAAAABaQEAAAAIcGF5WWllbGQAAAAABAAAAAtHb3Zlcm5Ub2tlbgEAAAAgvAZyzUx++c2P/OaSk4N3DovQ0UYK2akT0ub7yzxoPM0EAAAACmN1cnJlbnRLZXkJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAANY3VycmVudEFtb3VudAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAApjdXJyZW50S2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAADCQAAZgAAAAIFAAAADWN1cnJlbnRBbW91bnQAAAAAAAAAAAAEAAAAEUdvdmVyblRva2VuQW1vdW50CQAD6wAAAAIFAAAABHRoaXMFAAAAC0dvdmVyblRva2VuAwkAAGYAAAACAAAAAAAAAAABBQAAABFHb3Zlcm5Ub2tlbkFtb3VudAkAAAIAAAABAgAAACFObyBlbm91Z2ggR292ZXJuVG9rZW4gSW4gQ29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AAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAKd2luQWRkcmVzcwUAAAALUHJpemVBbW91bnQFAAAAD0NvbGxhdGVyYWxUb2tlbgUAAAADbmlsCQAAAgAAAAECAAAAOFlvdSBuZWVkIHRvIGhhdmUgZGVwb3NpdCBpbiB0aGUgQ29udHJhY3QgdG8gY2xhaW0gcmV3YXJkAAAAAGMT32Q=", "height": 1224890, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4ka5QdGkXJbnFjgSEn47uUq7eegRDrVwJmFQAfyf6R6g Next: DogKWkJZ2U9s7rrUKWLvtdwWRygno1fbtD1BmHA1Nf3K Diff:
Old | New | Differences | |
---|---|---|---|
15 | 15 | } | |
16 | 16 | if ((currentAmount > 0)) | |
17 | 17 | then { | |
18 | - | let | |
19 | - | if ((1 > | |
18 | + | let GovernTokenAmount = assetBalance(this, GovernToken) | |
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 | } | |
28 | 28 | @Callable(i) | |
29 | 29 | func deposit () = { | |
30 | 30 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
31 | + | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
31 | 32 | let pmt = extract(i.payment) | |
32 | 33 | if (if (isDefined(pmt.assetId)) | |
33 | 34 | then (extract(pmt.assetId) == CollateralToken) | |
41 | 42 | 0 | |
42 | 43 | } | |
43 | 44 | let newAmount = (currentAmount + pmt.amount) | |
44 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
45 | + | let GovernTokenAmount = assetBalance(this, GovernToken) | |
46 | + | if ((1 > GovernTokenAmount)) | |
47 | + | then throw("No enough GovernToken In Contract") | |
48 | + | else ScriptResult(WriteSet([DataEntry(currentKey, 10), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
45 | 49 | } | |
46 | 50 | else throw("Can deposit only MyToken") | |
47 | 51 | } | |
51 | 55 | @Callable(i) | |
52 | 56 | func withdrawFunds (amount) = { | |
53 | 57 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
58 | + | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
54 | 59 | let currentKey = toBase58String(i.caller.bytes) | |
55 | 60 | let currentAmount = match getInteger(this, currentKey) { | |
56 | 61 | case a: Int => | |
63 | 68 | then throw("Can't withdraw negative amount") | |
64 | 69 | else if ((0 > newAmount)) | |
65 | 70 | then throw("User cannot withdraw more than deposited funds") | |
66 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, CollateralToken)])) | |
71 | + | else { | |
72 | + | let GovernTokenAmount = assetBalance(this, GovernToken) | |
73 | + | if ((1 > GovernTokenAmount)) | |
74 | + | then throw("No enough GovernToken In Contract") | |
75 | + | else ScriptResult(WriteSet([DataEntry(currentKey, 1), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken), ScriptTransfer(i.caller, amount, CollateralToken)])) | |
76 | + | } | |
67 | 77 | } | |
68 | 78 | ||
69 | 79 |
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 | - | let | |
19 | - | if ((1 > | |
18 | + | let GovernTokenAmount = assetBalance(this, GovernToken) | |
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 deposit () = { | |
30 | 30 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
31 | + | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
31 | 32 | let pmt = extract(i.payment) | |
32 | 33 | if (if (isDefined(pmt.assetId)) | |
33 | 34 | then (extract(pmt.assetId) == CollateralToken) | |
34 | 35 | else false) | |
35 | 36 | then { | |
36 | 37 | let currentKey = toBase58String(i.caller.bytes) | |
37 | 38 | let currentAmount = match getInteger(this, currentKey) { | |
38 | 39 | case a: Int => | |
39 | 40 | a | |
40 | 41 | case _ => | |
41 | 42 | 0 | |
42 | 43 | } | |
43 | 44 | let newAmount = (currentAmount + pmt.amount) | |
44 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
45 | + | let GovernTokenAmount = assetBalance(this, GovernToken) | |
46 | + | if ((1 > GovernTokenAmount)) | |
47 | + | then throw("No enough GovernToken In Contract") | |
48 | + | else ScriptResult(WriteSet([DataEntry(currentKey, 10), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
45 | 49 | } | |
46 | 50 | else throw("Can deposit only MyToken") | |
47 | 51 | } | |
48 | 52 | ||
49 | 53 | ||
50 | 54 | ||
51 | 55 | @Callable(i) | |
52 | 56 | func withdrawFunds (amount) = { | |
53 | 57 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
58 | + | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
54 | 59 | let currentKey = toBase58String(i.caller.bytes) | |
55 | 60 | let currentAmount = match getInteger(this, currentKey) { | |
56 | 61 | case a: Int => | |
57 | 62 | a | |
58 | 63 | case _ => | |
59 | 64 | 0 | |
60 | 65 | } | |
61 | 66 | let newAmount = (currentAmount - amount) | |
62 | 67 | if ((0 > amount)) | |
63 | 68 | then throw("Can't withdraw negative amount") | |
64 | 69 | else if ((0 > newAmount)) | |
65 | 70 | then throw("User cannot withdraw more than deposited funds") | |
66 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, CollateralToken)])) | |
71 | + | else { | |
72 | + | let GovernTokenAmount = assetBalance(this, GovernToken) | |
73 | + | if ((1 > GovernTokenAmount)) | |
74 | + | then throw("No enough GovernToken In Contract") | |
75 | + | else ScriptResult(WriteSet([DataEntry(currentKey, 1), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken), ScriptTransfer(i.caller, amount, CollateralToken)])) | |
76 | + | } | |
67 | 77 | } | |
68 | 78 | ||
69 | 79 | ||
70 | 80 | ||
71 | 81 | @Callable(i) | |
72 | 82 | func ClaimPrize () = { | |
73 | 83 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
74 | 84 | let winnerPrize = "3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA" | |
75 | 85 | let FundBox = "3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD" | |
76 | 86 | let currentKey = toBase58String(i.caller.bytes) | |
77 | 87 | let winAddress = Address(base58'3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA') | |
78 | 88 | let FundBoxAddress = Address(base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD') | |
79 | 89 | let CallerAmount = match getInteger(this, currentKey) { | |
80 | 90 | case a: Int => | |
81 | 91 | a | |
82 | 92 | case _ => | |
83 | 93 | 0 | |
84 | 94 | } | |
85 | 95 | let PrizeAmount = match getInteger(this, FundBox) { | |
86 | 96 | case a: Int => | |
87 | 97 | a | |
88 | 98 | case _ => | |
89 | 99 | 0 | |
90 | 100 | } | |
91 | 101 | if ((PrizeAmount == 0)) | |
92 | 102 | then throw("No prize to Claim") | |
93 | 103 | else if ((currentKey != winnerPrize)) | |
94 | 104 | then throw("You are not the winner hence cannot claim the reward") | |
95 | 105 | else if ((CallerAmount > 0)) | |
96 | 106 | then ScriptResult(WriteSet([DataEntry(winnerPrize, PrizeAmount), DataEntry(FundBox, 0)]), TransferSet([ScriptTransfer(winAddress, PrizeAmount, CollateralToken)])) | |
97 | 107 | else throw("You need to have deposit in the Contract to claim reward") | |
98 | 108 | } | |
99 | 109 | ||
100 | 110 |
github/deemru/w8io/169f3d6 25.08 ms ◑