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:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAAAAAAAAgAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQEAAAAC2Jsb2NrSGVpZ2h0CAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAADcG10AAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAhY2FuIGhvZGwgd2F2ZXMgb25seSBhdCB0aGUgbW9tZW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQkAAGgAAAACCQAAaQAAAAIIBQAAAANwbXQ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AAB29sZERhdGEAAAAAAAAAAAAEAAAAC3N1bVdpdGhkcmF3CQAAZAAAAAIJAQAAAA1wYXJzZUludFZhbHVlAAAAAQkAAZEAAAACBQAAAAdvbGREYXRhAAAAAAAAAAACBQAAAAZhbW91bnQEAAAACW5ld0Ftb3VudAkAAGUAAAACBQAAAA1jdXJyZW50QW1vdW50BQAAAAZhbW91bnQDCQAAZgAAAAIAAAAAAAAAAAAFAAAABmFtb3VudAkAAAIAAAABAgAAAB5DYW4ndCB3aXRoZHJhdyBuZWdhdGl2ZSBhbW91bnQDCQAAZgAAAAIAAAAAAAAAAAAFAAAACW5ld0Ftb3VudAkAAAIAAAABAgAAABJOb3QgZW5vdWdoIGJhbGFuY2UJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApjdXJyZW50S2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAAJbmV3QW1vdW50AgAAAAFfCQABkQAAAAIFAAAAB29sZERhdGEAAAAAAAAAAAECAAAAAV8JAAGkAAAAAQUAAAALc3VtV2l0aGRyYXcFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAABmFtb3VudAUAAAAEdW5pdAUAAAADbmlsAAAAAC+vXKQ=",
"height": 1208857,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 586ZcYRTo8HF8KuQDaAj4hmdQyrSPizsY49SMgH43BNn
Next: ENDZPHbYLBjZPGNoHfaydWTVTPfHC1UjkWjSKuHJDUWJ
Diff:
Old | New | | Differences |
---|
6 | 6 | | @Callable(i) |
---|
7 | 7 | | func deposit () = { |
---|
8 | 8 | | let pmt = extract(i.payment) |
---|
9 | | - | let lbh = lastBlock.height |
---|
| 9 | + | let blockHeight = lastBlock.height |
---|
10 | 10 | | if (isDefined(pmt.assetId)) |
---|
11 | 11 | | then throw("can hodl waves only at the moment") |
---|
12 | 12 | | else { |
---|
13 | 13 | | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | 14 | | 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"))]) |
---|
16 | 16 | | else { |
---|
17 | 17 | | let oldData = split( match getString(this, currentKey) { |
---|
18 | 18 | | case str: String => |
---|
19 | 19 | | str |
---|
20 | 20 | | case _ => |
---|
21 | | - | throw("data string error") |
---|
| 21 | + | throw("error") |
---|
22 | 22 | | }, "_") |
---|
23 | 23 | | 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]))]) |
---|
25 | 25 | | } |
---|
26 | 26 | | } |
---|
| 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)])) |
---|
27 | 48 | | } |
---|
28 | 49 | | |
---|
29 | 50 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | 7 | | func deposit () = { |
---|
8 | 8 | | let pmt = extract(i.payment) |
---|
9 | | - | let lbh = lastBlock.height |
---|
| 9 | + | let blockHeight = lastBlock.height |
---|
10 | 10 | | if (isDefined(pmt.assetId)) |
---|
11 | 11 | | then throw("can hodl waves only at the moment") |
---|
12 | 12 | | else { |
---|
13 | 13 | | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | 14 | | 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"))]) |
---|
16 | 16 | | else { |
---|
17 | 17 | | let oldData = split( match getString(this, currentKey) { |
---|
18 | 18 | | case str: String => |
---|
19 | 19 | | str |
---|
20 | 20 | | case _ => |
---|
21 | | - | throw("data string error") |
---|
| 21 | + | throw("error") |
---|
22 | 22 | | }, "_") |
---|
23 | 23 | | 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]))]) |
---|
25 | 25 | | } |
---|
26 | 26 | | } |
---|
| 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)])) |
---|
27 | 48 | | } |
---|
28 | 49 | | |
---|
29 | 50 | | |
---|