tx · 9Xzu6pFWaVUc8GuKsNnXr9S42xtAGmwMG2qZ1JBAkwpd 3MsaXCT52ggYJWZtBEwQJPTrMQcX8zQpABa: -0.01400000 Waves 2021.12.20 15:11 [1842562] smart account 3MsaXCT52ggYJWZtBEwQJPTrMQcX8zQpABa > SELF 0.00000000 Waves
{ "type": 13, "id": "9Xzu6pFWaVUc8GuKsNnXr9S42xtAGmwMG2qZ1JBAkwpd", "fee": 1400000, "feeAssetId": null, "timestamp": 1640002330330, "version": 2, "chainId": 84, "sender": "3MsaXCT52ggYJWZtBEwQJPTrMQcX8zQpABa", "senderPublicKey": "3uLRwuGsawQLLWXXct1U2P3ePeRdUZjsv8YZatXH6kBR", "proofs": [ "dnTvsCJuFnRLWkqmv3D8CVU3W6eC5QRfRVfsX2rHCWR1utaGjWoovJ4mNQhwfRMCCWzwBz5MA4VdAG68dC16snf" ], "script": "base64:AAIFAAAAAAAAAIkIAhIAEgMKAQEaBgoBYRIBaRoICgFiEgNwbXQaDwoBYxIKY3VycmVudEtleRoSCgFkEg1jdXJyZW50QW1vdW50GgwKAWUSByRtYXRjaDAaBgoBZhIBYRoOCgFnEgluZXdBbW91bnQaCwoBaBIGYW1vdW50GgcKAWkSAnR4GgsKAWoSBnZlcmlmeQAAAAAAAAACAAAAAWEBAAAACWNyZWF0ZU5GVAAAAAAEAAAAAWIDCQAAAAAAAAIJAAGQAAAAAQgFAAAAAWEAAAAIcGF5bWVudHMAAAAAAAAAAAEJAAGRAAAAAggFAAAAAWEAAAAIcGF5bWVudHMAAAAAAAAAAAAJAAACAAAAAQIAAAAcQXR0YWNoZWQgcGF5bWVudCBpcyByZXF1aXJlZAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAABYgAAAAdhc3NldElkCQAAAgAAAAECAAAAFXdvcmtzIHdpdGggd2F2ZXMgb25seQQAAAABYwkAAlgAAAABCAgFAAAAAWEAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAAFkBAAAAAFlCQAEGgAAAAIFAAAABHRoaXMFAAAAAWMDCQAAAQAAAAIFAAAAAWUCAAAAA0ludAQAAAABZgUAAAABZQUAAAABZgAAAAAAAAAAAAQAAAABZwkAAGQAAAACBQAAAAFkCAUAAAABYgAAAAZhbW91bnQJAAUUAAAAAgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAABYwUAAAABZwUAAAADbmlsBQAAAAR1bml0AAAAAWEBAAAACHdpdGhkcmF3AAAAAQAAAAFoBAAAAAFjCQACWAAAAAEICAUAAAABYQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAAAWQEAAAAAWUJAAQaAAAAAgUAAAAEdGhpcwUAAAABYwMJAAABAAAAAgUAAAABZQIAAAADSW50BAAAAAFmBQAAAAFlBQAAAAFmAAAAAAAAAAAABAAAAAFnCQAAZQAAAAIFAAAAAWQFAAAAAWgDCQAAZgAAAAIAAAAAAAAAAAAFAAAAAWgJAAACAAAAAQIAAAAeQ2FuJ3Qgd2l0aGRyYXcgbmVnYXRpdmUgYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAAAFnCQAAAgAAAAECAAAAEk5vdCBlbm91Z2ggYmFsYW5jZQkABRQAAAACCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAFjBQAAAAFnCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFhAAAABmNhbGxlcgUAAAABaAUAAAAEdW5pdAUAAAADbmlsBQAAAAR1bml0AAAAAQAAAAFpAQAAAAFqAAAAAAkAAfQAAAADCAUAAAABaQAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAWkAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAABaQAAAA9zZW5kZXJQdWJsaWNLZXkiJpht", "height": 1842562, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DkhXEFE3tWUrnw6UmawoacjPHryfSxyZzcu5XETCPwMZ Next: 5vbyniGSLfDtFnKoYbHdk5TSpF9pykw8Gx5dDF221mwF Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func tryGetInteger (key) = { | |
5 | - | let val = match getInteger(this, key) { | |
6 | - | case b: Int => | |
7 | - | b | |
4 | + | ||
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func createNFT () = { | |
8 | + | let pmt = if ((size(i.payments) == 1)) | |
9 | + | then i.payments[0] | |
10 | + | else throw("Attached payment is required") | |
11 | + | if (isDefined(pmt.assetId)) | |
12 | + | then throw("works with waves only") | |
13 | + | else { | |
14 | + | let currentKey = toBase58String(i.caller.bytes) | |
15 | + | let currentAmount = match getInteger(this, currentKey) { | |
16 | + | case a: Int => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | let newAmount = (currentAmount + pmt.amount) | |
22 | + | $Tuple2([IntegerEntry(currentKey, newAmount)], unit) | |
23 | + | } | |
24 | + | } | |
25 | + | ||
26 | + | ||
27 | + | ||
28 | + | @Callable(i) | |
29 | + | func withdraw (amount) = { | |
30 | + | let currentKey = toBase58String(i.caller.bytes) | |
31 | + | let currentAmount = match getInteger(this, currentKey) { | |
32 | + | case a: Int => | |
33 | + | a | |
8 | 34 | case _ => | |
9 | 35 | 0 | |
10 | 36 | } | |
11 | - | val | |
12 | - | } | |
13 | - | ||
14 | - | ||
15 | - | @Callable(i) | |
16 | - | func issueFreeDuckling (address,txIdStr) = { | |
17 | - | let asset = Issue("BABY-11111111-GZ", "", 1, 0, false, unit, height) | |
18 | - | let assetId = calculateAssetId(asset) | |
19 | - | $Tuple2([StringEntry((((address + "_") + txIdStr) + "_di"), toBase58String(assetId)), IntegerEntry("stats_amount", (tryGetInteger("stats_amount") + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], "") | |
37 | + | let newAmount = (currentAmount - amount) | |
38 | + | if ((0 > amount)) | |
39 | + | then throw("Can't withdraw negative amount") | |
40 | + | else if ((0 > newAmount)) | |
41 | + | then throw("Not enough balance") | |
42 | + | else $Tuple2([IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)], unit) | |
20 | 43 | } | |
21 | 44 | ||
22 | 45 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func tryGetInteger (key) = { | |
5 | - | let val = match getInteger(this, key) { | |
6 | - | case b: Int => | |
7 | - | b | |
4 | + | ||
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func createNFT () = { | |
8 | + | let pmt = if ((size(i.payments) == 1)) | |
9 | + | then i.payments[0] | |
10 | + | else throw("Attached payment is required") | |
11 | + | if (isDefined(pmt.assetId)) | |
12 | + | then throw("works with waves only") | |
13 | + | else { | |
14 | + | let currentKey = toBase58String(i.caller.bytes) | |
15 | + | let currentAmount = match getInteger(this, currentKey) { | |
16 | + | case a: Int => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | let newAmount = (currentAmount + pmt.amount) | |
22 | + | $Tuple2([IntegerEntry(currentKey, newAmount)], unit) | |
23 | + | } | |
24 | + | } | |
25 | + | ||
26 | + | ||
27 | + | ||
28 | + | @Callable(i) | |
29 | + | func withdraw (amount) = { | |
30 | + | let currentKey = toBase58String(i.caller.bytes) | |
31 | + | let currentAmount = match getInteger(this, currentKey) { | |
32 | + | case a: Int => | |
33 | + | a | |
8 | 34 | case _ => | |
9 | 35 | 0 | |
10 | 36 | } | |
11 | - | val | |
12 | - | } | |
13 | - | ||
14 | - | ||
15 | - | @Callable(i) | |
16 | - | func issueFreeDuckling (address,txIdStr) = { | |
17 | - | let asset = Issue("BABY-11111111-GZ", "", 1, 0, false, unit, height) | |
18 | - | let assetId = calculateAssetId(asset) | |
19 | - | $Tuple2([StringEntry((((address + "_") + txIdStr) + "_di"), toBase58String(assetId)), IntegerEntry("stats_amount", (tryGetInteger("stats_amount") + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], "") | |
37 | + | let newAmount = (currentAmount - amount) | |
38 | + | if ((0 > amount)) | |
39 | + | then throw("Can't withdraw negative amount") | |
40 | + | else if ((0 > newAmount)) | |
41 | + | then throw("Not enough balance") | |
42 | + | else $Tuple2([IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)], unit) | |
20 | 43 | } | |
21 | 44 | ||
22 | 45 | ||
23 | 46 | @Verifier(tx) | |
24 | 47 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
25 | 48 |
github/deemru/w8io/169f3d6 40.44 ms ◑