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