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