tx · A8Yw9ax5SumPgTnALVFDudNTzuNawLsYqntFZ762M2oH 3N9yCRmNsLK2aPStjLBne3EUiPSKvVHYgKk: -0.05000000 Waves 2020.10.05 10:27 [1206960] smart account 3N9yCRmNsLK2aPStjLBne3EUiPSKvVHYgKk > SELF 0.00000000 Waves
{ "type": 13, "id": "A8Yw9ax5SumPgTnALVFDudNTzuNawLsYqntFZ762M2oH", "fee": 5000000, "feeAssetId": null, "timestamp": 1601882855172, "version": 2, "chainId": 84, "sender": "3N9yCRmNsLK2aPStjLBne3EUiPSKvVHYgKk", "senderPublicKey": "7nLAwoiRA4fWF4VHd6gRsbwF2UFFmRADXHqRcgy3h27w", "proofs": [ "Ubessd1GKZzxPYnwP7j1p4xgEoBDc9PCQqu4nuNs4rEd1pnyirHDMmKkx2TvyX39CPgkLyJXunVDZ9xB1cxFFEX" ], "script": "base64:AAIEAAAAAAAAAAkIAhIAEgMKAQEAAAAAAAAAAgAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAFdmFsdWUAAAABCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAAAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAkAAAIAAAABAgAAABV3b3JrcyB3aXRoIHdhdmVzIG9ubHkEAAAACmN1cnJlbnRLZXkJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAANY3VycmVudEFtb3VudAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAApjdXJyZW50S2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAEAAAACW5ld0Ftb3VudAkAAGQAAAACBQAAAA1jdXJyZW50QW1vdW50CAUAAAADcG10AAAABmFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAKY3VycmVudEtleQUAAAAJbmV3QW1vdW50BQAAAANuaWwAAAABaQEAAAAId2l0aGRyYXcAAAABAAAABmFtb3VudAQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAQAAAAJbmV3QW1vdW50CQAAZQAAAAIFAAAADWN1cnJlbnRBbW91bnQFAAAABmFtb3VudAMJAABmAAAAAgAAAAAAAAAAAAUAAAAGYW1vdW50CQAAAgAAAAECAAAAHkNhbid0IHdpdGhkcmF3IG5lZ2F0aXZlIGFtb3VudAMJAABmAAAAAgAAAAAAAAAAAAUAAAAJbmV3QW1vdW50CQAAAgAAAAECAAAAEk5vdCBlbm91Z2ggYmFsYW5jZQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAKY3VycmVudEtleQUAAAAJbmV3QW1vdW50CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAGYW1vdW50BQAAAAR1bml0BQAAAANuaWwAAAAAQLnszw==", "height": 1206960, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CLunczyZF2LBDrj68iUwnyxRasNED3godnxN55d7KRsA Next: 3tHLN5ZZHp2SjmvX6R7QxoxSdqh2UbDYgc64Jg3PV5dz Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | - | @Callable(inv) | |
7 | - | func foo () = { | |
8 | - | let issue = Issue("CryptoRouble", "Description", 1000, 2, true) | |
9 | - | let id = calculateAssetId(issue) | |
10 | - | [issue, BinaryEntry("id", id)] | |
6 | + | @Callable(i) | |
7 | + | func deposit () = { | |
8 | + | let pmt = value(i.payments[0]) | |
9 | + | if (isDefined(pmt.assetId)) | |
10 | + | then throw("works with waves only") | |
11 | + | else { | |
12 | + | let currentKey = toBase58String(i.caller.bytes) | |
13 | + | let currentAmount = match getInteger(this, currentKey) { | |
14 | + | case a: Int => | |
15 | + | a | |
16 | + | case _ => | |
17 | + | 0 | |
18 | + | } | |
19 | + | let newAmount = (currentAmount + pmt.amount) | |
20 | + | [IntegerEntry(currentKey, newAmount)] | |
21 | + | } | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | ||
26 | + | @Callable(i) | |
27 | + | func withdraw (amount) = { | |
28 | + | let currentKey = toBase58String(i.caller.bytes) | |
29 | + | let currentAmount = match getInteger(this, currentKey) { | |
30 | + | case a: Int => | |
31 | + | a | |
32 | + | case _ => | |
33 | + | 0 | |
34 | + | } | |
35 | + | let newAmount = (currentAmount - amount) | |
36 | + | if ((0 > amount)) | |
37 | + | then throw("Can't withdraw negative amount") | |
38 | + | else if ((0 > newAmount)) | |
39 | + | then throw("Not enough balance") | |
40 | + | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)] | |
11 | 41 | } | |
12 | 42 | ||
13 | 43 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | - | @Callable(inv) | |
7 | - | func foo () = { | |
8 | - | let issue = Issue("CryptoRouble", "Description", 1000, 2, true) | |
9 | - | let id = calculateAssetId(issue) | |
10 | - | [issue, BinaryEntry("id", id)] | |
6 | + | @Callable(i) | |
7 | + | func deposit () = { | |
8 | + | let pmt = value(i.payments[0]) | |
9 | + | if (isDefined(pmt.assetId)) | |
10 | + | then throw("works with waves only") | |
11 | + | else { | |
12 | + | let currentKey = toBase58String(i.caller.bytes) | |
13 | + | let currentAmount = match getInteger(this, currentKey) { | |
14 | + | case a: Int => | |
15 | + | a | |
16 | + | case _ => | |
17 | + | 0 | |
18 | + | } | |
19 | + | let newAmount = (currentAmount + pmt.amount) | |
20 | + | [IntegerEntry(currentKey, newAmount)] | |
21 | + | } | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | ||
26 | + | @Callable(i) | |
27 | + | func withdraw (amount) = { | |
28 | + | let currentKey = toBase58String(i.caller.bytes) | |
29 | + | let currentAmount = match getInteger(this, currentKey) { | |
30 | + | case a: Int => | |
31 | + | a | |
32 | + | case _ => | |
33 | + | 0 | |
34 | + | } | |
35 | + | let newAmount = (currentAmount - amount) | |
36 | + | if ((0 > amount)) | |
37 | + | then throw("Can't withdraw negative amount") | |
38 | + | else if ((0 > newAmount)) | |
39 | + | then throw("Not enough balance") | |
40 | + | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)] | |
11 | 41 | } | |
12 | 42 | ||
13 | 43 |
github/deemru/w8io/169f3d6 51.56 ms ◑