tx · Eqoq9oCA2F4T66fveqxApo9aYaZAfVXZdCqdnA6dkzUi
3N8qSbKKrQztCYcZyhcRqNkgxQ1gcv2gN1D: -0.00200000 Waves
2022.07.14 16:50 [2139473] smart account 3N8qSbKKrQztCYcZyhcRqNkgxQ1gcv2gN1D > SELF 0.00000000 Waves
{
"type": 13,
"id": "Eqoq9oCA2F4T66fveqxApo9aYaZAfVXZdCqdnA6dkzUi",
"fee": 200000,
"feeAssetId": null,
"timestamp": 1657806710926,
"version": 2,
"chainId": 84,
"sender": "3N8qSbKKrQztCYcZyhcRqNkgxQ1gcv2gN1D",
"senderPublicKey": "5Y54ygDeR7kKoUTD7MTiRm9VhShh4jyPhqyHznn4wFJ4",
"proofs": [
"4zePkKSXM9GbKw6t4mCiBARJiYTw3RrLvXkf3rH1gjut9MK9Hz6vijvbusy72no955mrQQ3Sk2paBkrgggZiBgRy"
],
"script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAAAAAAAAgAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAAJaXNEZWZpbmVkAAAAAQgFAAAAA3BtdAAAAAdhc3NldElkCQAAAgAAAAECAAAAIWNhbiBob2RsIHdhdmVzIG9ubHkgYXQgdGhlIG1vbWVudAQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAQAAAAJbmV3QW1vdW50CQAAZAAAAAIFAAAADWN1cnJlbnRBbW91bnQIBQAAAANwbXQAAAAGYW1vdW50CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAApjdXJyZW50S2V5BQAAAAluZXdBbW91bnQFAAAAA25pbAAAAAFpAQAAAAh3aXRoZHJhdwAAAAEAAAAGYW1vdW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAADWN1cnJlbnRBbW91bnQEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAKY3VycmVudEtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABAAAAAluZXdBbW91bnQJAABlAAAAAgUAAAANY3VycmVudEFtb3VudAUAAAAGYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAAAZhbW91bnQJAAACAAAAAQIAAAAeQ2FuJ3Qgd2l0aGRyYXcgbmVnYXRpdmUgYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAAAluZXdBbW91bnQJAAACAAAAAQIAAAASTm90IGVub3VnaCBiYWxhbmNlCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAKY3VycmVudEtleQUAAAAJbmV3QW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAH+vmYeA==",
"height": 2139473,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 3SWxDxatWxYmrMebQghJuLBAVLxfVdXGS6NmS1AdJTcd
Next: none
Diff:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let ggToken = base58'8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h' |
---|
5 | 4 | | |
---|
6 | | - | func startLotto (inv) = { |
---|
7 | | - | let pmt = extract(inv.payment) |
---|
8 | | - | if ((pmt.assetId != ggToken)) |
---|
9 | | - | then throw("ggToken 8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h tokens only at the moment") |
---|
| 5 | + | |
---|
| 6 | + | @Callable(i) |
---|
| 7 | + | func deposit () = { |
---|
| 8 | + | let pmt = extract(i.payment) |
---|
| 9 | + | if (isDefined(pmt.assetId)) |
---|
| 10 | + | then throw("can hodl waves only at the moment") |
---|
10 | 11 | | else { |
---|
11 | | - | let currentKey = toBase58String(inv.caller.bytes) |
---|
| 12 | + | let currentKey = toBase58String(i.caller.bytes) |
---|
12 | 13 | | let currentAmount = match getInteger(this, currentKey) { |
---|
13 | 14 | | case a: Int => |
---|
14 | 15 | | a |
---|
|
21 | 22 | | } |
---|
22 | 23 | | |
---|
23 | 24 | | |
---|
24 | | - | @Callable(inv) |
---|
25 | | - | func deposit () = startLotto(inv) |
---|
26 | 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 ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
| 41 | + | } |
---|
| 42 | + | |
---|
| 43 | + | |
---|
| 44 | + | @Verifier(tx) |
---|
| 45 | + | func verify () = false |
---|
27 | 46 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let ggToken = base58'8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h' |
---|
5 | 4 | | |
---|
6 | | - | func startLotto (inv) = { |
---|
7 | | - | let pmt = extract(inv.payment) |
---|
8 | | - | if ((pmt.assetId != ggToken)) |
---|
9 | | - | then throw("ggToken 8Dyidvq8ykWxmv6CxZZXQtdj1aktiwPv4ibgGWTgxo5h tokens only at the moment") |
---|
| 5 | + | |
---|
| 6 | + | @Callable(i) |
---|
| 7 | + | func deposit () = { |
---|
| 8 | + | let pmt = extract(i.payment) |
---|
| 9 | + | if (isDefined(pmt.assetId)) |
---|
| 10 | + | then throw("can hodl waves only at the moment") |
---|
10 | 11 | | else { |
---|
11 | | - | let currentKey = toBase58String(inv.caller.bytes) |
---|
| 12 | + | let currentKey = toBase58String(i.caller.bytes) |
---|
12 | 13 | | let currentAmount = match getInteger(this, currentKey) { |
---|
13 | 14 | | case a: Int => |
---|
14 | 15 | | a |
---|
15 | 16 | | case _ => |
---|
16 | 17 | | 0 |
---|
17 | 18 | | } |
---|
18 | 19 | | let newAmount = (currentAmount + pmt.amount) |
---|
19 | 20 | | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
20 | 21 | | } |
---|
21 | 22 | | } |
---|
22 | 23 | | |
---|
23 | 24 | | |
---|
24 | | - | @Callable(inv) |
---|
25 | | - | func deposit () = startLotto(inv) |
---|
26 | 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 ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
| 41 | + | } |
---|
| 42 | + | |
---|
| 43 | + | |
---|
| 44 | + | @Verifier(tx) |
---|
| 45 | + | func verify () = false |
---|
27 | 46 | | |
---|