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