tx · 54iJvH9CJ31ZvRyq9v2DNk3AzVSzKA6ZrG5EGNdradGW 3MyBgxRjsj4dFVLNqZVMpJuqFcchA1rfdPd: -0.05000000 Waves 2019.10.17 00:31 [723090] smart account 3MyBgxRjsj4dFVLNqZVMpJuqFcchA1rfdPd > SELF 0.00000000 Waves
{ "type": 13, "id": "54iJvH9CJ31ZvRyq9v2DNk3AzVSzKA6ZrG5EGNdradGW", "fee": 5000000, "feeAssetId": null, "timestamp": 1571261394619, "version": 1, "sender": "3MyBgxRjsj4dFVLNqZVMpJuqFcchA1rfdPd", "senderPublicKey": "FNveiFvnZxbJ2nmWHcE42V2V1LQV3qAtmdpvbFnTimVG", "proofs": [ "2hgZKgqRDiD1kqDoCb4TJhVBVoodhkcBcHe4jpwY63MJoPA8qvUUZGuA3EaWKs9zMH9eJ7essa3MMUxUVh2udw9X" ], "script": "base64:AAIDAAAAAAAAAAwIARIDCgEIEgMKAQEAAAATAAAAAAl3YXZlc0xldHMAAAAAAAX14QAAAAAADlRvdGFsQW1vdW50S2V5AgAAAAtUb3RhbEFtb3VudAAAAAASVG90YWxBbW91bnRMZWZ0S2V5AgAAAA9Ub3RhbEFtb3VudExlZnQAAAAAEVVuaXF1ZVNwb25zb3JzS2V5AgAAAA5VbmlxdWVTcG9uc29ycwAAAAAJRmVlUHVia2V5AQAAACAok4ZZcGaRC+s2MKC22dBEPDzVWEOIB9nM7V46PClPeQAAAAAJRmVlV2FsbGV0CQEAAAAUYWRkcmVzc0Zyb21QdWJsaWNLZXkAAAABBQAAAAlGZWVQdWJrZXkAAAAADnJlY2VpdmVyUHViS2V5AQAAACAlbSP+mgMlNuu7HG4M1vuMOYBvzRL+YwXaxGu6HTwDKwAAAAAIcmVjZWl2ZXIJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAADnJlY2VpdmVyUHViS2V5AAAAAAdBc3NldGlkAgAAACw0NDdQV3dlcVRRUEY5YW5VS3RrbkR4N2ZOc0d6SENWZ3NiV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gUAAAAOTGFzdFBheW1lbnRLZXkFAAAABmhlaWdodAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAACHJlY2VpdmVyBQAAAA5XaXRoZHJhd0Ftb3VudAUAAAAEdW5pdAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAlGZWVXYWxsZXQFAAAACUZlZUFtb3VudAUAAAAEdW5pdAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAFzBQAAAAckbWF0Y2gwBgdjhxj/", "chainId": 84, "height": 723090, "spentComplexity": 0 } View: original | compacted Prev: 67i6kSx1JJWo93FNdP4McdgJSRZ8rJd3ZChRFiDYxT78 Next: Ha6uniSDKBytp5p617nXV3SNJHWbo12fMZXHRq6Wfeyd Diff:
Old | New | Differences | |
---|---|---|---|
26 | 26 | let MaxSalary = 1 | |
27 | 27 | ||
28 | 28 | let Fee = 2 | |
29 | + | ||
30 | + | let test = 1 | |
29 | 31 | ||
30 | 32 | func getNumberByKey (key) = { | |
31 | 33 | let num = match getInteger(this, key) { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let wavesLets = 100000000 | |
5 | 5 | ||
6 | 6 | let TotalAmountKey = "TotalAmount" | |
7 | 7 | ||
8 | 8 | let TotalAmountLeftKey = "TotalAmountLeft" | |
9 | 9 | ||
10 | 10 | let UniqueSponsorsKey = "UniqueSponsors" | |
11 | 11 | ||
12 | 12 | let FeePubkey = base58'3jPnDZ2dMwgNS3NJKwrRaov4EsEygKfrnHPyQDD2bfk4' | |
13 | 13 | ||
14 | 14 | let FeeWallet = addressFromPublicKey(FeePubkey) | |
15 | 15 | ||
16 | 16 | let receiverPubKey = base58'3X6cLkhy6PLoJ5uJdjke6a3ikfEW8Msf62CaoHRY8YWv' | |
17 | 17 | ||
18 | 18 | let receiver = addressFromPublicKey(receiverPubKey) | |
19 | 19 | ||
20 | 20 | let Assetid = "447PWweqTQPF9anUKtknDx7fNsGzHCVgsbVJiP8FSGdt" | |
21 | 21 | ||
22 | 22 | let LastPaymentKey = "LastPayment" | |
23 | 23 | ||
24 | 24 | let PaymentTimeout = 10 | |
25 | 25 | ||
26 | 26 | let MaxSalary = 1 | |
27 | 27 | ||
28 | 28 | let Fee = 2 | |
29 | + | ||
30 | + | let test = 1 | |
29 | 31 | ||
30 | 32 | func getNumberByKey (key) = { | |
31 | 33 | let num = match getInteger(this, key) { | |
32 | 34 | case a: Int => | |
33 | 35 | a | |
34 | 36 | case _ => | |
35 | 37 | 0 | |
36 | 38 | } | |
37 | 39 | num | |
38 | 40 | } | |
39 | 41 | ||
40 | 42 | ||
41 | 43 | func GetKeySponsor (sponsor) = (sponsor + "_sponsor") | |
42 | 44 | ||
43 | 45 | ||
44 | 46 | func GetKeySponsorAmount (sponsor) = (sponsor + "_amount") | |
45 | 47 | ||
46 | 48 | ||
47 | 49 | func GetSponsorAmount (sponsor) = getNumberByKey(GetKeySponsorAmount(sponsor)) | |
48 | 50 | ||
49 | 51 | ||
50 | 52 | func CheckUniqueSponsor (sponsor,count) = { | |
51 | 53 | let returnval = match getString(this, GetKeySponsor(sponsor)) { | |
52 | 54 | case a: String => | |
53 | 55 | count | |
54 | 56 | case _ => | |
55 | 57 | (count + 1) | |
56 | 58 | } | |
57 | 59 | returnval | |
58 | 60 | } | |
59 | 61 | ||
60 | 62 | ||
61 | 63 | @Callable(i) | |
62 | 64 | func deposit (sponsor) = { | |
63 | 65 | let pmt = extract(i.payment) | |
64 | 66 | if ((pmt.assetId != toBytes(Assetid))) | |
65 | 67 | then throw("Only Assetid can be deposited") | |
66 | 68 | else { | |
67 | 69 | let currentKey = toBase58String(i.caller.bytes) | |
68 | 70 | let currentAmount = getNumberByKey(currentKey) | |
69 | 71 | let CurrSponsorAmount = GetSponsorAmount(currentKey) | |
70 | 72 | let currentTotalAmount = getNumberByKey(TotalAmountKey) | |
71 | 73 | let currentAmountLeft = getNumberByKey(TotalAmountLeftKey) | |
72 | 74 | let UniqueSponsorCount = getNumberByKey(UniqueSponsorsKey) | |
73 | 75 | let newUniqueSponsorCount = CheckUniqueSponsor(currentKey, UniqueSponsorCount) | |
74 | 76 | let newSponsorAmount = (CurrSponsorAmount + pmt.amount) | |
75 | 77 | let newAmount = (currentAmount + pmt.amount) | |
76 | 78 | let newtotalAmount = (currentTotalAmount + pmt.amount) | |
77 | 79 | let newtotalamountleft = (currentAmountLeft + pmt.amount) | |
78 | 80 | WriteSet([DataEntry(currentKey, newAmount), DataEntry(TotalAmountKey, newtotalAmount), DataEntry(TotalAmountLeftKey, newtotalamountleft), DataEntry(GetKeySponsorAmount(currentKey), newSponsorAmount), DataEntry(GetKeySponsor(currentKey), toBytes(sponsor)), DataEntry(UniqueSponsorsKey, newUniqueSponsorCount)]) | |
79 | 81 | } | |
80 | 82 | } | |
81 | 83 | ||
82 | 84 | ||
83 | 85 | ||
84 | 86 | @Callable(i) | |
85 | 87 | func withdraw (amount) = { | |
86 | 88 | let currentKey = toBase58String(i.caller.bytes) | |
87 | 89 | let AllowedSigner = (i.caller == receiver) | |
88 | 90 | let FeeAmount = ((amount * Fee) / 100) | |
89 | 91 | let WithdrawAmount = (amount - FeeAmount) | |
90 | 92 | let currentAmountLeft = match getInteger(this, TotalAmountLeftKey) { | |
91 | 93 | case a: Int => | |
92 | 94 | a | |
93 | 95 | case _ => | |
94 | 96 | 0 | |
95 | 97 | } | |
96 | 98 | let lastPayment = match getInteger(this, LastPaymentKey) { | |
97 | 99 | case a: Int => | |
98 | 100 | a | |
99 | 101 | case _ => | |
100 | 102 | 0 | |
101 | 103 | } | |
102 | 104 | if (!(AllowedSigner)) | |
103 | 105 | then throw("Withdraw is only allowed by recipient") | |
104 | 106 | else if (((lastPayment + PaymentTimeout) > height)) | |
105 | 107 | then throw("Next payment not yet allowed") | |
106 | 108 | else { | |
107 | 109 | let newAmountLeft = (currentAmountLeft - amount) | |
108 | 110 | if ((0 > amount)) | |
109 | 111 | then throw("Can't withdraw negative amount") | |
110 | 112 | else if ((amount > (MaxSalary * wavesLets))) | |
111 | 113 | then throw((("Not allowed to withdraw more than " + toString(MaxSalary)) + " WAVES")) | |
112 | 114 | else if ((0 > newAmountLeft)) | |
113 | 115 | then throw("Not enough balance") | |
114 | 116 | else ScriptResult(WriteSet([DataEntry(TotalAmountLeftKey, newAmountLeft), DataEntry(LastPaymentKey, height)]), TransferSet([ScriptTransfer(receiver, WithdrawAmount, unit), ScriptTransfer(FeeWallet, FeeAmount, unit)])) | |
115 | 117 | } | |
116 | 118 | } | |
117 | 119 | ||
118 | 120 | ||
119 | 121 | @Verifier(tx) | |
120 | 122 | func verify () = match tx { | |
121 | 123 | case s: SetScriptTransaction => | |
122 | 124 | true | |
123 | 125 | case _ => | |
124 | 126 | false | |
125 | 127 | } | |
126 | 128 |
github/deemru/w8io/169f3d6 43.93 ms ◑