tx · ySfmQTJN883eV5tRAxPW4tbNhBatKFMbyYKCrZThxzu

3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY:  -0.01400000 Waves

2020.10.06 18:09 [1208857] smart account 3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY > SELF 0.00000000 Waves

{ "type": 13, "id": "ySfmQTJN883eV5tRAxPW4tbNhBatKFMbyYKCrZThxzu", "fee": 1400000, "feeAssetId": null, "timestamp": 1601996947310, "version": 2, "chainId": 84, "sender": "3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY", "senderPublicKey": "HhWoKsFPjXVx9nYfPydpV9BwLmuUdJyJ8ydtyVJVxg9Z", "proofs": [ "2MgHZu5gBcTss2aej6f9HASrox1o5w8N5TwoVQxoG7rg5mVx5FLjxPbN3FZP5Ketb8KLTq9GmusjDnjE7JHV4G7N" ], "script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAAAAAAAAgAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQEAAAAC2Jsb2NrSGVpZ2h0CAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAADcG10AAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAhY2FuIGhvZGwgd2F2ZXMgb25seSBhdCB0aGUgbW9tZW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQkAAGgAAAACCQAAaQAAAAIIBQAAAANwbXQAAAAGYW1v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GEAAAAAAAAAAAAEAAAAC3N1bVdpdGhkcmF3CQAAZAAAAAIJAQAAAA1wYXJzZUludFZhbHVlAAAAAQkAAZEAAAACBQAAAAdvbGREYXRhAAAAAAAAAAACBQAAAAZhbW91bnQEAAAACW5ld0Ftb3VudAkAAGUAAAACBQAAAA1jdXJyZW50QW1vdW50BQAAAAZhbW91bnQDCQAAZgAAAAIAAAAAAAAAAAAFAAAABmFtb3VudAkAAAIAAAABAgAAAB5DYW4ndCB3aXRoZHJhdyBuZWdhdGl2ZSBhbW91bnQDCQAAZgAAAAIAAAAAAAAAAAAFAAAACW5ld0Ftb3VudAkAAAIAAAABAgAAABJOb3QgZW5vdWdoIGJhbGFuY2UJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApjdXJyZW50S2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAAJbmV3QW1vdW50AgAAAAFfCQABkQAAAAIFAAAAB29sZERhdGEAAAAAAAAAAAECAAAAAV8JAAGkAAAAAQUAAAALc3VtV2l0aGRyYXcFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAABmFtb3VudAUAAAAEdW5pdAUAAAADbmlsAAAAAC+vXKQ=", "height": 1208857, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 586ZcYRTo8HF8KuQDaAj4hmdQyrSPizsY49SMgH43BNn Next: ENDZPHbYLBjZPGNoHfaydWTVTPfHC1UjkWjSKuHJDUWJ Diff:
OldNewDifferences
66 @Callable(i)
77 func deposit () = {
88 let pmt = extract(i.payment)
9- let lbh = lastBlock.height
9+ let blockHeight = lastBlock.height
1010 if (isDefined(pmt.assetId))
1111 then throw("can hodl waves only at the moment")
1212 else {
1313 let currentKey = toBase58String(i.caller.bytes)
1414 if (!(isDefined(getString(this, currentKey))))
15- then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(lbh)) + "_0"))])
15+ then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(blockHeight)) + "_0"))])
1616 else {
1717 let oldData = split( match getString(this, currentKey) {
1818 case str: String =>
1919 str
2020 case _ =>
21- throw("data string error")
21+ throw("error")
2222 }, "_")
2323 let currentAmount = parseIntValue(oldData[0])
24- WriteSet([DataEntry(currentKey, ((((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(lbh)) + "_") + oldData[2]))])
24+ WriteSet([DataEntry(currentKey, ((((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(blockHeight)) + "_") + oldData[2]))])
2525 }
2626 }
27+ }
28+
29+
30+
31+@Callable(i)
32+func withdraw (amount) = {
33+ let currentKey = toBase58String(i.caller.bytes)
34+ let oldData = split( match getString(this, currentKey) {
35+ case str: String =>
36+ str
37+ case _ =>
38+ throw("error")
39+ }, "_")
40+ let currentAmount = parseIntValue(oldData[0])
41+ let sumWithdraw = (parseIntValue(oldData[2]) + amount)
42+ let newAmount = (currentAmount - amount)
43+ if ((0 > amount))
44+ then throw("Can't withdraw negative amount")
45+ else if ((0 > newAmount))
46+ then throw("Not enough balance")
47+ else ScriptResult(WriteSet([DataEntry(currentKey, ((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)))]), TransferSet([ScriptTransfer(i.caller, amount, unit)]))
2748 }
2849
2950
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44
55
66 @Callable(i)
77 func deposit () = {
88 let pmt = extract(i.payment)
9- let lbh = lastBlock.height
9+ let blockHeight = lastBlock.height
1010 if (isDefined(pmt.assetId))
1111 then throw("can hodl waves only at the moment")
1212 else {
1313 let currentKey = toBase58String(i.caller.bytes)
1414 if (!(isDefined(getString(this, currentKey))))
15- then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(lbh)) + "_0"))])
15+ then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(blockHeight)) + "_0"))])
1616 else {
1717 let oldData = split( match getString(this, currentKey) {
1818 case str: String =>
1919 str
2020 case _ =>
21- throw("data string error")
21+ throw("error")
2222 }, "_")
2323 let currentAmount = parseIntValue(oldData[0])
24- WriteSet([DataEntry(currentKey, ((((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(lbh)) + "_") + oldData[2]))])
24+ WriteSet([DataEntry(currentKey, ((((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(blockHeight)) + "_") + oldData[2]))])
2525 }
2626 }
27+ }
28+
29+
30+
31+@Callable(i)
32+func withdraw (amount) = {
33+ let currentKey = toBase58String(i.caller.bytes)
34+ let oldData = split( match getString(this, currentKey) {
35+ case str: String =>
36+ str
37+ case _ =>
38+ throw("error")
39+ }, "_")
40+ let currentAmount = parseIntValue(oldData[0])
41+ let sumWithdraw = (parseIntValue(oldData[2]) + amount)
42+ let newAmount = (currentAmount - amount)
43+ if ((0 > amount))
44+ then throw("Can't withdraw negative amount")
45+ else if ((0 > newAmount))
46+ then throw("Not enough balance")
47+ else ScriptResult(WriteSet([DataEntry(currentKey, ((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)))]), TransferSet([ScriptTransfer(i.caller, amount, unit)]))
2748 }
2849
2950

github/deemru/w8io/169f3d6 
34.42 ms