tx · 4sxfrA26HCjTiS8nvLZm596VCGSzNukBUEzGvAPXbu5G 3MxbD7vwyGjwsRxT8fmMB9fngo59VfHcrea: -0.00500000 Waves 2022.08.18 21:10 [2190262] smart account 3MxbD7vwyGjwsRxT8fmMB9fngo59VfHcrea > SELF 0.00000000 Waves
{ "type": 13, "id": "4sxfrA26HCjTiS8nvLZm596VCGSzNukBUEzGvAPXbu5G", "fee": 500000, "feeAssetId": null, "timestamp": 1660846252992, "version": 2, "chainId": 84, "sender": "3MxbD7vwyGjwsRxT8fmMB9fngo59VfHcrea", "senderPublicKey": "7kBiESqWjiW6nNeStcbrVX9XRQkWmUM51MZFRZNQEVfR", "proofs": [ "3jcCFWbDGQcEb5BoPPk3EbNtgZ84CaG9uvMDSrVNvkQMubNnZq4tL8YZtboEbRYJjopa9Dfzo1ZZ7eeGeR38vjf5" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAAwAAAAAFYWRtaW4BAAAAGgFU2PM7U36jhOCUm0OgJsYfuFEOVaPqmlIkAAAAAAtjb2FsQXNzZXRJZAEAAAAgMeDV9UC3cemF7HoOb7evUrojvKZCHJ2aO5kl6ImGjuYBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAAAAAEAAAABaQEAAAAIbWludE5hemkAAAAABAAAAAZjYWxsZXIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAIbGFzdE1pbnQJAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQkAASwAAAACAgAAAAlsYXN0TWludF8FAAAABmNhbGxlcgMDCQAAZgAAAAIFAAAACGxhc3RNaW50AAAAAAAAAAAACQAAZgAAAAIJAABkAAAAAgUAAAAIbGFzdE1pbnQAAAAAAAAAAAUFAAAABmhlaWdodAcJAAACAAAAAQIAAAApWW91IG5lZWQgdG8gd2FpdCA1IGJsb2NrcyBhZnRlciBsYXN0IG1pbnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAJbGFzdE1pbnRfBQAAAAZjYWxsZXIFAAAABmhlaWdodAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAC2NvYWxBc3NldElkAAAAAAAAAAABBgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAAC2NvYWxBc3NldElkBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlebOdjyw=", "height": 2190262, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4BEKofSW3htD5skc4QeF1jTXyJKNHJCo4vz6c6mp8cen Next: AMTmWknLTqJmBSgN7jgk2LLmvqVpDTpgciCkWMSgbXzW Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let admin = base58' | |
4 | + | let admin = base58'3N9hD7PnazZB7wbwFmr7fw28UKXj593YmTR' | |
5 | 5 | ||
6 | 6 | let coalAssetId = base58'4MhpjsP1MPpC49v6zBr7eAAEPZdmHWcrSqcSv8tZcpjo' | |
7 | 7 | ||
11 | 11 | case _ => | |
12 | 12 | 0 | |
13 | 13 | } | |
14 | - | ||
15 | - | ||
16 | - | func tryGetBoolean (key) = match getBoolean(this, key) { | |
17 | - | case b: Boolean => | |
18 | - | b | |
19 | - | case _ => | |
20 | - | false | |
21 | - | } | |
22 | - | ||
23 | - | ||
24 | - | func getAssetString (assetId) = match assetId { | |
25 | - | case b: ByteVector => | |
26 | - | toBase58String(b) | |
27 | - | case _ => | |
28 | - | "WAVES" | |
29 | - | } | |
30 | - | ||
31 | - | ||
32 | - | func tryGetString (key) = match getString(this, key) { | |
33 | - | case b: String => | |
34 | - | b | |
35 | - | case _ => | |
36 | - | "" | |
37 | - | } | |
38 | - | ||
39 | - | ||
40 | - | func tryGetBinary (key) = match getBinary(this, key) { | |
41 | - | case b: ByteVector => | |
42 | - | b | |
43 | - | case _ => | |
44 | - | base58'' | |
45 | - | } | |
46 | - | ||
47 | - | ||
48 | - | func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES")) | |
49 | - | then unit | |
50 | - | else fromBase58String(assetIdStr) | |
51 | - | ||
52 | - | ||
53 | - | @Callable(i) | |
54 | - | func createFurnace (lifetime) = if ((toBase58String(i.caller.bytes) != toBase58String(admin))) | |
55 | - | then throw("You cannot create furnace") | |
56 | - | else if ((size(i.payments) != 1)) | |
57 | - | then throw("You should to provide reward") | |
58 | - | else { | |
59 | - | let rewardAmount = i.payments[0].amount | |
60 | - | let rewardAssetId = i.payments[0].assetId | |
61 | - | let newFurnacesAmount = (tryGetInteger("global_furnacesAmount") + 1) | |
62 | - | let furnaceId = toString(newFurnacesAmount) | |
63 | - | [IntegerEntry("global_furnacesAmount", newFurnacesAmount), IntegerEntry((("furnace_" + furnaceId) + "_lifetime"), lifetime), IntegerEntry((("furnace_" + furnaceId) + "_rewardAmount"), rewardAmount), StringEntry((("furnace_" + furnaceId) + "_rewardAssetId"), getAssetString(rewardAssetId))] | |
64 | - | } | |
65 | - | ||
66 | - | ||
67 | - | ||
68 | - | @Callable(i) | |
69 | - | func burn (furnaceId) = { | |
70 | - | let isFinished = tryGetBoolean((("furnace_" + furnaceId) + "_finished")) | |
71 | - | let lifetime = tryGetInteger((("furnace_" + furnaceId) + "_lifetime")) | |
72 | - | let lastBurn = tryGetInteger((("furnace_" + furnaceId) + "_lastBurn")) | |
73 | - | let finisHeight = (lastBurn + lifetime) | |
74 | - | if (isFinished) | |
75 | - | then throw("Already finished") | |
76 | - | else if ((lifetime == 0)) | |
77 | - | then throw("Cannot find furnace") | |
78 | - | else if (if ((lastBurn > 0)) | |
79 | - | then (height >= finisHeight) | |
80 | - | else false) | |
81 | - | then throw("Time is run out") | |
82 | - | else if ((size(i.payments) != 1)) | |
83 | - | then throw("You should to provide payment") | |
84 | - | else if ((i.payments[0].assetId != coalAssetId)) | |
85 | - | then throw("Invalid coal") | |
86 | - | else if ((i.payments[0].amount != 1)) | |
87 | - | then throw("You can burn only 1 coal") | |
88 | - | else { | |
89 | - | let callerAddress = toBase58String(i.caller.bytes) | |
90 | - | [Burn(coalAssetId, i.payments[0].amount), IntegerEntry((("furnace_" + furnaceId) + "_lastBurn"), height), StringEntry((("furnace_" + furnaceId) + "_lastStoker"), callerAddress)] | |
91 | - | } | |
92 | - | } | |
93 | - | ||
94 | - | ||
95 | - | ||
96 | - | @Callable(i) | |
97 | - | func claim (furnaceId) = { | |
98 | - | let isFinished = tryGetBoolean((("furnace_" + furnaceId) + "_finished")) | |
99 | - | let lifetime = tryGetInteger((("furnace_" + furnaceId) + "_lifetime")) | |
100 | - | let lastBurn = tryGetInteger((("furnace_" + furnaceId) + "_lastBurn")) | |
101 | - | let rewardAsset = tryGetString((("furnace_" + furnaceId) + "_rewardAssetId")) | |
102 | - | let lastStoker = tryGetString((("furnace_" + furnaceId) + "_lastStoker")) | |
103 | - | let rewardAmount = tryGetInteger((("furnace_" + furnaceId) + "_rewardAmount")) | |
104 | - | let finishHeight = (lastBurn + lifetime) | |
105 | - | if (isFinished) | |
106 | - | then throw("Already finished") | |
107 | - | else if ((lifetime == 0)) | |
108 | - | then throw("Cannot find furnace") | |
109 | - | else if ((lastBurn == 0)) | |
110 | - | then throw("Furnace not found") | |
111 | - | else if ((finishHeight > height)) | |
112 | - | then throw("Time has not run out") | |
113 | - | else if ((rewardAsset == "")) | |
114 | - | then throw("Cannot find reward asset") | |
115 | - | else if ((lastStoker == "")) | |
116 | - | then throw("Cannot find last stoker") | |
117 | - | else if ((rewardAmount == 0)) | |
118 | - | then throw("Reward already sent to winner") | |
119 | - | else [BooleanEntry((("furnace_" + furnaceId) + "_finished"), true), ScriptTransfer(Address(fromBase58String(lastStoker)), rewardAmount, getAssetBytes(rewardAsset))] | |
120 | - | } | |
121 | - | ||
122 | 14 | ||
123 | 15 | ||
124 | 16 | @Callable(i) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let admin = base58' | |
4 | + | let admin = base58'3N9hD7PnazZB7wbwFmr7fw28UKXj593YmTR' | |
5 | 5 | ||
6 | 6 | let coalAssetId = base58'4MhpjsP1MPpC49v6zBr7eAAEPZdmHWcrSqcSv8tZcpjo' | |
7 | 7 | ||
8 | 8 | func tryGetInteger (key) = match getInteger(this, key) { | |
9 | 9 | case b: Int => | |
10 | 10 | b | |
11 | 11 | case _ => | |
12 | 12 | 0 | |
13 | 13 | } | |
14 | - | ||
15 | - | ||
16 | - | func tryGetBoolean (key) = match getBoolean(this, key) { | |
17 | - | case b: Boolean => | |
18 | - | b | |
19 | - | case _ => | |
20 | - | false | |
21 | - | } | |
22 | - | ||
23 | - | ||
24 | - | func getAssetString (assetId) = match assetId { | |
25 | - | case b: ByteVector => | |
26 | - | toBase58String(b) | |
27 | - | case _ => | |
28 | - | "WAVES" | |
29 | - | } | |
30 | - | ||
31 | - | ||
32 | - | func tryGetString (key) = match getString(this, key) { | |
33 | - | case b: String => | |
34 | - | b | |
35 | - | case _ => | |
36 | - | "" | |
37 | - | } | |
38 | - | ||
39 | - | ||
40 | - | func tryGetBinary (key) = match getBinary(this, key) { | |
41 | - | case b: ByteVector => | |
42 | - | b | |
43 | - | case _ => | |
44 | - | base58'' | |
45 | - | } | |
46 | - | ||
47 | - | ||
48 | - | func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES")) | |
49 | - | then unit | |
50 | - | else fromBase58String(assetIdStr) | |
51 | - | ||
52 | - | ||
53 | - | @Callable(i) | |
54 | - | func createFurnace (lifetime) = if ((toBase58String(i.caller.bytes) != toBase58String(admin))) | |
55 | - | then throw("You cannot create furnace") | |
56 | - | else if ((size(i.payments) != 1)) | |
57 | - | then throw("You should to provide reward") | |
58 | - | else { | |
59 | - | let rewardAmount = i.payments[0].amount | |
60 | - | let rewardAssetId = i.payments[0].assetId | |
61 | - | let newFurnacesAmount = (tryGetInteger("global_furnacesAmount") + 1) | |
62 | - | let furnaceId = toString(newFurnacesAmount) | |
63 | - | [IntegerEntry("global_furnacesAmount", newFurnacesAmount), IntegerEntry((("furnace_" + furnaceId) + "_lifetime"), lifetime), IntegerEntry((("furnace_" + furnaceId) + "_rewardAmount"), rewardAmount), StringEntry((("furnace_" + furnaceId) + "_rewardAssetId"), getAssetString(rewardAssetId))] | |
64 | - | } | |
65 | - | ||
66 | - | ||
67 | - | ||
68 | - | @Callable(i) | |
69 | - | func burn (furnaceId) = { | |
70 | - | let isFinished = tryGetBoolean((("furnace_" + furnaceId) + "_finished")) | |
71 | - | let lifetime = tryGetInteger((("furnace_" + furnaceId) + "_lifetime")) | |
72 | - | let lastBurn = tryGetInteger((("furnace_" + furnaceId) + "_lastBurn")) | |
73 | - | let finisHeight = (lastBurn + lifetime) | |
74 | - | if (isFinished) | |
75 | - | then throw("Already finished") | |
76 | - | else if ((lifetime == 0)) | |
77 | - | then throw("Cannot find furnace") | |
78 | - | else if (if ((lastBurn > 0)) | |
79 | - | then (height >= finisHeight) | |
80 | - | else false) | |
81 | - | then throw("Time is run out") | |
82 | - | else if ((size(i.payments) != 1)) | |
83 | - | then throw("You should to provide payment") | |
84 | - | else if ((i.payments[0].assetId != coalAssetId)) | |
85 | - | then throw("Invalid coal") | |
86 | - | else if ((i.payments[0].amount != 1)) | |
87 | - | then throw("You can burn only 1 coal") | |
88 | - | else { | |
89 | - | let callerAddress = toBase58String(i.caller.bytes) | |
90 | - | [Burn(coalAssetId, i.payments[0].amount), IntegerEntry((("furnace_" + furnaceId) + "_lastBurn"), height), StringEntry((("furnace_" + furnaceId) + "_lastStoker"), callerAddress)] | |
91 | - | } | |
92 | - | } | |
93 | - | ||
94 | - | ||
95 | - | ||
96 | - | @Callable(i) | |
97 | - | func claim (furnaceId) = { | |
98 | - | let isFinished = tryGetBoolean((("furnace_" + furnaceId) + "_finished")) | |
99 | - | let lifetime = tryGetInteger((("furnace_" + furnaceId) + "_lifetime")) | |
100 | - | let lastBurn = tryGetInteger((("furnace_" + furnaceId) + "_lastBurn")) | |
101 | - | let rewardAsset = tryGetString((("furnace_" + furnaceId) + "_rewardAssetId")) | |
102 | - | let lastStoker = tryGetString((("furnace_" + furnaceId) + "_lastStoker")) | |
103 | - | let rewardAmount = tryGetInteger((("furnace_" + furnaceId) + "_rewardAmount")) | |
104 | - | let finishHeight = (lastBurn + lifetime) | |
105 | - | if (isFinished) | |
106 | - | then throw("Already finished") | |
107 | - | else if ((lifetime == 0)) | |
108 | - | then throw("Cannot find furnace") | |
109 | - | else if ((lastBurn == 0)) | |
110 | - | then throw("Furnace not found") | |
111 | - | else if ((finishHeight > height)) | |
112 | - | then throw("Time has not run out") | |
113 | - | else if ((rewardAsset == "")) | |
114 | - | then throw("Cannot find reward asset") | |
115 | - | else if ((lastStoker == "")) | |
116 | - | then throw("Cannot find last stoker") | |
117 | - | else if ((rewardAmount == 0)) | |
118 | - | then throw("Reward already sent to winner") | |
119 | - | else [BooleanEntry((("furnace_" + furnaceId) + "_finished"), true), ScriptTransfer(Address(fromBase58String(lastStoker)), rewardAmount, getAssetBytes(rewardAsset))] | |
120 | - | } | |
121 | - | ||
122 | 14 | ||
123 | 15 | ||
124 | 16 | @Callable(i) | |
125 | 17 | func mintNazi () = { | |
126 | 18 | let caller = toBase58String(i.caller.bytes) | |
127 | 19 | let lastMint = tryGetInteger(("lastMint_" + caller)) | |
128 | 20 | if (if ((lastMint > 0)) | |
129 | 21 | then ((lastMint + 5) > height) | |
130 | 22 | else false) | |
131 | 23 | then throw("You need to wait 5 blocks after last mint") | |
132 | 24 | else [IntegerEntry(("lastMint_" + caller), height), Reissue(coalAssetId, 1, true), ScriptTransfer(i.caller, 1, coalAssetId)] | |
133 | 25 | } | |
134 | 26 | ||
135 | 27 | ||
136 | 28 | @Verifier(tx) | |
137 | 29 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
138 | 30 |
github/deemru/w8io/026f985 25.57 ms ◑