tx · DRPS2GubMdKx99a7UaqyrzRstnZdCZaWWYjo4mSAyahm 3N1WYGqfoXEG9F7UvMfHqSEyphXEDuAMvDB: -0.01400000 Waves 2019.07.05 19:58 [572467] smart account 3N1WYGqfoXEG9F7UvMfHqSEyphXEDuAMvDB > SELF 0.00000000 Waves
{ "type": 13, "id": "DRPS2GubMdKx99a7UaqyrzRstnZdCZaWWYjo4mSAyahm", "fee": 1400000, "feeAssetId": null, "timestamp": 1562345932147, "version": 1, "sender": "3N1WYGqfoXEG9F7UvMfHqSEyphXEDuAMvDB", "senderPublicKey": "3Vwh6XFkVS7FzMVfQLSNEUG48z7YumcE7bSNqmRo7k69", "proofs": [ "4gpotBpaLELmWXVLsU6xzwYjYX9StjYphGNCMUUzEyRWZPnQc2AKvCyjA4pXguB1HmfzTWXX7HkZMb7oWjCgvc5V" ], "script": "base64:AAIDAAAAAAAAAAAAAAAMAAAAAAZsZXZlbDEAAAAAAAAAAPoAAAAABmxldmVsMgAAAAAAAAAA+gAAAAAGbGV2ZWwzAAAAAAAAAAD6AAAAAAhjYXNoQmFjawAAAAAAAAAA+gAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAAttaW5XaXRoZHJhdwAAAAAAAA9CQAAAAAAOY2hhbmdlT3duZXJLZXkCAAAALEFEMnZienBSM1pNWGlZMVpoQmRxNGlIMXd6NXc2dFVDSFB6MXZ2TmZ5Q3FFAQAAABBiYWxhbmNlSW5jcmVtZW50AAAAAgAAAAdhZGRyZXNzAAAAA2luYwQAAAAKYmFsYW5jZUtleQkAASwAAAACBQAAAAdhZGRyZXNzAgAAAAhfYmFsYW5jZQkBAAAACURhdGFFbnRyeQAAAAIFAAAACmJhbGFuY2VLZXkJAABkAAAAAgUAAAADaW5jBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmJhbGFuY2VLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAA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XRSZWZlcmVyAAAAAQUAAAAHcmVmZXJlcgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAhyZWZlcmVyMgUAAAAHJG1hdGNoMAkAASwAAAACCQABLAAAAAICAAAAASwFAAAACHJlZmVyZXIyBAAAAAckbWF0Y2gxCQEAAAAKZ2V0UmVmZXJlcgAAAAEFAAAACHJlZmVyZXIyAwkAAAEAAAACBQAAAAckbWF0Y2gxAgAAAAZTdHJpbmcEAAAACHJlZmVyZXIzBQAAAAckbWF0Y2gxCQABLAAAAAICAAAAASwFAAAACHJlZmVyZXIzAgAAAAACAAAAAAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAFb3duZXICAAAACF9yZWZlcmVyBQAAAAdyZWZlcmVyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAtyZWZlcmFsc0tleQUAAAAIcmVmZXJhbHMJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAFb3duZXICAAAADV9yZWZzdHJ1Y3R1cmUFAAAADHJlZlN0cnVjdHVyZQUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcggFAAAAAWkAAAADZmVlBQAAAAR1bml0BQAAAANuaWwAAAAA/gqiWA==", "chainId": 84, "height": 572467, "spentComplexity": 0 } View: original | compacted Prev: Cc1ju72eztdrxq1cZ4KMGWKVnKMhtZW8bDU4QLyC5QjC Next: ExYYRLYjt31HtRiRe7ApstB5yJpowHFTPPCRTLmqaWVp Diff:
Old | New | Differences | |
---|---|---|---|
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | - | func recordBalanceIncrement (address,owner,inc,level,txId,timestamp) = DataEntry(("fund_" + txId), (((((((address + ":") + owner) + ":") + toString(inc)) + ":") + level) + ":")) | |
29 | + | func recordBalanceIncrement (address,owner,inc,level,txId,timestamp) = DataEntry(((("fund_" + address) + "_") + txId), (((((((address + ":") + owner) + ":") + toString(inc)) + ":") + level) + ":")) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getReferer (user) = getString(this, (user + "_referer")) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let level1 = 250 | |
5 | 5 | ||
6 | 6 | let level2 = 250 | |
7 | 7 | ||
8 | 8 | let level3 = 250 | |
9 | 9 | ||
10 | 10 | let cashBack = 250 | |
11 | 11 | ||
12 | 12 | let maxFee = 5000000 | |
13 | 13 | ||
14 | 14 | let minWithdraw = 1000000 | |
15 | 15 | ||
16 | 16 | let changeOwnerKey = "AD2vbzpR3ZMXiY1ZhBdq4iH1wz5w6tUCHPz1vvNfyCqE" | |
17 | 17 | ||
18 | 18 | func balanceIncrement (address,inc) = { | |
19 | 19 | let balanceKey = (address + "_balance") | |
20 | 20 | DataEntry(balanceKey, (inc + match getInteger(this, balanceKey) { | |
21 | 21 | case b: Int => | |
22 | 22 | b | |
23 | 23 | case _ => | |
24 | 24 | 0 | |
25 | 25 | })) | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | - | func recordBalanceIncrement (address,owner,inc,level,txId,timestamp) = DataEntry(("fund_" + txId), (((((((address + ":") + owner) + ":") + toString(inc)) + ":") + level) + ":")) | |
29 | + | func recordBalanceIncrement (address,owner,inc,level,txId,timestamp) = DataEntry(((("fund_" + address) + "_") + txId), (((((((address + ":") + owner) + ":") + toString(inc)) + ":") + level) + ":")) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getReferer (user) = getString(this, (user + "_referer")) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func checkFee (i) = if ((i.fee > maxFee)) | |
36 | 36 | then throw("unreasonable large fee") | |
37 | 37 | else true | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getTimestamp () = { | |
41 | 41 | let block = extract(blockInfoByHeight(height)) | |
42 | 42 | toString(block.timestamp) | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | @Callable(i) | |
47 | 47 | func fund () = { | |
48 | 48 | let owner = toBase58String(i.caller.bytes) | |
49 | 49 | let txid = toBase58String(i.transactionId) | |
50 | 50 | let timestamp = getTimestamp() | |
51 | 51 | let amount = extract(i.payment).amount | |
52 | 52 | let cf = checkFee(i) | |
53 | 53 | ScriptResult(WriteSet( match getString(this, (owner + "_refstructure")) { | |
54 | 54 | case refListS: String => | |
55 | 55 | let refList = split(refListS, ",") | |
56 | 56 | let refListSize = size(refList) | |
57 | 57 | let incLevel1 = ((amount * level1) / 1000) | |
58 | 58 | let incCashBack = ((amount * cashBack) / 1000) | |
59 | 59 | [balanceIncrement(owner, incCashBack), recordBalanceIncrement(owner, owner, incCashBack, "_txs_cashback", txid, timestamp), balanceIncrement(refList[0], incLevel1), recordBalanceIncrement(refList[0], owner, incLevel1, "_txs_l1", txid, timestamp), if ((refListSize >= 2)) | |
60 | 60 | then { | |
61 | 61 | let incLevel2 = ((amount * level2) / 1000) | |
62 | 62 | [balanceIncrement(refList[1], incLevel2), recordBalanceIncrement(refList[1], owner, incLevel2, "_txs_l2", txid, timestamp), if ((refListSize >= 3)) | |
63 | 63 | then { | |
64 | 64 | let incLevel3 = ((amount * level3) / 1000) | |
65 | 65 | [balanceIncrement(refList[2], incLevel3), recordBalanceIncrement(refList[2], owner, incLevel3, "_txs_l3", txid, timestamp), balanceIncrement(changeOwnerKey, (((amount - incLevel1) - incLevel2) - incLevel3)), recordBalanceIncrement(changeOwnerKey, owner, (((amount - incLevel1) - incLevel2) - incLevel3), "_txs_change", txid, timestamp)] | |
66 | 66 | } | |
67 | 67 | else [balanceIncrement(changeOwnerKey, ((amount - incLevel1) - incLevel2)), recordBalanceIncrement(changeOwnerKey, owner, ((amount - incLevel1) - incLevel2), "_txs_change", txid, timestamp)]] | |
68 | 68 | } | |
69 | 69 | else [balanceIncrement(changeOwnerKey, (amount - incLevel1)), recordBalanceIncrement(changeOwnerKey, owner, (amount - incLevel1), "_txs_change", txid, timestamp)]] | |
70 | 70 | case _ => | |
71 | 71 | [balanceIncrement(changeOwnerKey, amount), recordBalanceIncrement(changeOwnerKey, owner, amount, "_txs_change", txid, timestamp)] | |
72 | 72 | }), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | @Callable(i) | |
78 | 78 | func withdraw () = { | |
79 | 79 | let cf = checkFee(i) | |
80 | 80 | let owner = toBase58String(i.caller.bytes) | |
81 | 81 | let balanceKey = (owner + "_balance") | |
82 | 82 | let amount = match getInteger(this, balanceKey) { | |
83 | 83 | case b: Int => | |
84 | 84 | b | |
85 | 85 | case _ => | |
86 | 86 | 0 | |
87 | 87 | } | |
88 | 88 | if ((minWithdraw > amount)) | |
89 | 89 | then throw(("Min withdraw amount is" + toString(minWithdraw))) | |
90 | 90 | else { | |
91 | 91 | let withdrawTxKey = (owner + "_withdraw_txs") | |
92 | 92 | let record = ((((toString(amount) + ":") + toBase58String(i.transactionId)) + ":") + getTimestamp()) | |
93 | 93 | let withdrawTxList = match getString(this, withdrawTxKey) { | |
94 | 94 | case prevTxs: String => | |
95 | 95 | ((prevTxs + ",") + record) | |
96 | 96 | case _ => | |
97 | 97 | record | |
98 | 98 | } | |
99 | 99 | ScriptResult(WriteSet([DataEntry(balanceKey, 0), DataEntry(withdrawTxKey, withdrawTxList)]), TransferSet([ScriptTransfer(i.caller, (amount + i.fee), unit)])) | |
100 | 100 | } | |
101 | 101 | } | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Callable(i) | |
106 | 106 | func register (referer,salt) = { | |
107 | 107 | let cf = checkFee(i) | |
108 | 108 | if ((take(toBase58String(i.transactionId), 3) != "123")) | |
109 | 109 | then throw("proof of work failed") | |
110 | 110 | else { | |
111 | 111 | let owner = toBase58String(i.caller.bytes) | |
112 | 112 | if (isDefined(getReferer(owner))) | |
113 | 113 | then throw("Already registered") | |
114 | 114 | else { | |
115 | 115 | let referalsKey = (referer + "_referrals") | |
116 | 116 | let referals = match getString(this, referalsKey) { | |
117 | 117 | case oldRefs: String => | |
118 | 118 | ((oldRefs + ",") + owner) | |
119 | 119 | case _ => | |
120 | 120 | owner | |
121 | 121 | } | |
122 | 122 | let refStructure = (referer + match getReferer(referer) { | |
123 | 123 | case referer2: String => | |
124 | 124 | (("," + referer2) + match getReferer(referer2) { | |
125 | 125 | case referer3: String => | |
126 | 126 | ("," + referer3) | |
127 | 127 | case _ => | |
128 | 128 | "" | |
129 | 129 | }) | |
130 | 130 | case _ => | |
131 | 131 | "" | |
132 | 132 | }) | |
133 | 133 | ScriptResult(WriteSet([DataEntry((owner + "_referer"), referer), DataEntry(referalsKey, referals), DataEntry((owner + "_refstructure"), refStructure)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit)])) | |
134 | 134 | } | |
135 | 135 | } | |
136 | 136 | } | |
137 | 137 | ||
138 | 138 |
github/deemru/w8io/026f985 47.11 ms ◑