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+gAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAA5jaGFuZ2VPd25lcktleQIAAAAsQUQydmJ6cFIzWk1YaVkxWmhCZHE0aUgxd3o1dzZ0VUNIUHoxdnZOZnlDcUUBAAAAEGJhbGFuY2VJbmNyZW1lbnQAAAACAAAAB2FkZHJlc3MAAAADaW5jBAAAAApiYWxhbmNlS2V5CQABLAAAAAIFAAAAB2FkZHJlc3MCAAAACF9iYWxhbmNlCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAKYmFsYW5jZUtleQkAAGQAAAACBQAAAANpbmMEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAKYmFsYW5jZUtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAABVpbmRleEJhbGFuY2VJbmNyZW1l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AAABLAUAAAAIcmVmZXJlcjMCAAAAAAIAAAAACQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAVvd25lcgIAAAAIX3JlZmVyZXIFAAAAB3JlZmVyZXIJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAC3JlZmVyYWxzS2V5BQAAAAhyZWZlcmFscwkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAVvd25lcgIAAAANX3JlZnN0cnVjdHVyZQUAAAAMcmVmU3RydWN0dXJlBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyCAUAAAABaQAAAANmZWUFAAAABHVuaXQFAAAAA25pbAAAAAD2xAJm", "chainId": 84, "height": 567836, "spentComplexity": 0 } View: original | compacted Prev: CSi5Msk2ANvEZxvSeREWgmP4A9jYK5Gfqagv5GwfX47 Next: 8xuvB84GiyhToGqbiqnzneqWyWmbhQT437RH4nnoRDm6 Diff:
OldNewDifferences
4444 else true
4545
4646
47+func getTimestamp () = {
48+ let block = extract(blockInfoByHeight(height))
49+ toString(block.timestamp)
50+ }
51+
52+
4753 @Callable(i)
4854 func fund () = {
4955 let owner = toBase58String(i.callerPublicKey)
50- let block = extract(blockInfoByHeight(height))
51- let ownerColon = (((owner + ":") + toString(block.timestamp)) + ":")
56+ let ownerColon = ((owner + ":") + getTimestamp())
5257 let amount = extract(i.payment).amount
5358 let cf = checkFee(i)
5459 ScriptResult(WriteSet( match getString(this, (owner + "_refstructure")) {
7984 func withdraw () = {
8085 let cf = checkFee(i)
8186 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) {
8389 case b: Int =>
8490 b
8591 case _ =>
8692 0
8793 }
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
89101 }
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+ }
95104
96105
97106
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let level1 = 250
55
66 let level2 = 250
77
88 let level3 = 250
99
1010 let cashBack = 250
1111
1212 let maxFee = 5000000
1313
1414 let changeOwnerKey = "AD2vbzpR3ZMXiY1ZhBdq4iH1wz5w6tUCHPz1vvNfyCqE"
1515
1616 func balanceIncrement (address,inc) = {
1717 let balanceKey = (address + "_balance")
1818 DataEntry(balanceKey, (inc + match getInteger(this, balanceKey) {
1919 case b: Int =>
2020 b
2121 case _ =>
2222 0
2323 }))
2424 }
2525
2626
2727 func indexBalanceIncrement (address,owner,inc,level) = {
2828 let logKey = (address + level)
2929 let recordData = (owner + toString(inc))
3030 match getString(this, logKey) {
3131 case prev: String =>
3232 DataEntry(logKey, ((prev + ",") + recordData))
3333 case _ =>
3434 DataEntry(logKey, recordData)
3535 }
3636 }
3737
3838
3939 func getReferer (user) = getString(this, (user + "_referer"))
4040
4141
4242 func checkFee (i) = if ((i.fee > maxFee))
4343 then throw("unreasonable large fee")
4444 else true
4545
4646
47+func getTimestamp () = {
48+ let block = extract(blockInfoByHeight(height))
49+ toString(block.timestamp)
50+ }
51+
52+
4753 @Callable(i)
4854 func fund () = {
4955 let owner = toBase58String(i.callerPublicKey)
50- let block = extract(blockInfoByHeight(height))
51- let ownerColon = (((owner + ":") + toString(block.timestamp)) + ":")
56+ let ownerColon = ((owner + ":") + getTimestamp())
5257 let amount = extract(i.payment).amount
5358 let cf = checkFee(i)
5459 ScriptResult(WriteSet( match getString(this, (owner + "_refstructure")) {
5560 case refListS: String =>
5661 let refList = split(refListS, ",")
5762 let refListSize = size(refList)
5863 let incLevel1 = ((amount * level1) / 1000)
5964 let incCashBack = ((amount * cashBack) / 1000)
6065 [balanceIncrement(owner, incCashBack), indexBalanceIncrement(owner, ownerColon, incCashBack, "_txs_cashback"), balanceIncrement(refList[0], incLevel1), indexBalanceIncrement(refList[0], ownerColon, incLevel1, "_txs_l1"), if ((refListSize >= 2))
6166 then {
6267 let incLevel2 = ((amount * level2) / 1000)
6368 [balanceIncrement(refList[1], incLevel2), indexBalanceIncrement(refList[1], ownerColon, incLevel2, "_txs_l2"), if ((refListSize >= 3))
6469 then {
6570 let incLevel3 = ((amount * level3) / 1000)
6671 [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")]
6772 }
6873 else [balanceIncrement(changeOwnerKey, ((amount - incLevel1) - incLevel2)), indexBalanceIncrement(changeOwnerKey, ownerColon, ((amount - incLevel1) - incLevel2), "_txs_change")]]
6974 }
7075 else [balanceIncrement(changeOwnerKey, (amount - incLevel1)), indexBalanceIncrement(changeOwnerKey, ownerColon, (amount - incLevel1), "_txs_change")]]
7176 case _ =>
7277 [balanceIncrement(changeOwnerKey, amount), indexBalanceIncrement(changeOwnerKey, ownerColon, amount, "_txs_change")]
7378 }), TransferSet([ScriptTransfer(i.caller, i.fee, unit)]))
7479 }
7580
7681
7782
7883 @Callable(i)
7984 func withdraw () = {
8085 let cf = checkFee(i)
8186 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) {
8389 case b: Int =>
8490 b
8591 case _ =>
8692 0
8793 }
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
89101 }
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+ }
95104
96105
97106
98107 @Callable(i)
99108 func register (referer,salt) = {
100109 let cf = checkFee(i)
101110 if ((take(toBase58String(i.transactionId), 3) != "123"))
102111 then throw("proof of work failed")
103112 else {
104113 let owner = toBase58String(i.callerPublicKey)
105114 if (isDefined(getReferer(owner)))
106115 then throw("Already registered")
107116 else {
108117 let referalsKey = (referer + "_referrals")
109118 let referals = match getString(this, referalsKey) {
110119 case oldRefs: String =>
111120 ((oldRefs + ",") + owner)
112121 case _ =>
113122 owner
114123 }
115124 let refStructure = (referer + match getReferer(referer) {
116125 case referer2: String =>
117126 (("," + referer2) + match getReferer(referer2) {
118127 case referer3: String =>
119128 ("," + referer3)
120129 case _ =>
121130 ""
122131 })
123132 case _ =>
124133 ""
125134 })
126135 ScriptResult(WriteSet([DataEntry((owner + "_referer"), referer), DataEntry(referalsKey, referals), DataEntry((owner + "_refstructure"), refStructure)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit)]))
127136 }
128137 }
129138 }
130139
131140

github/deemru/w8io/169f3d6 
69.37 ms