evm-transactions-tools 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ [comment]: <> (SPDX-License-Identifier: AGPL-3.0)
2
+
3
+ [comment]: <> (------------------------------------------------------)
4
+ [comment]: <> (Copyright © 2024, 2025, 2026 Pellegrino Prevete)
5
+ [comment]: <> (All rights reserved)
6
+ [comment]: <> (------------------------------------------------------)
7
+
8
+ [comment]: <> (This program is free software: you can redistribute)
9
+ [comment]: <> (it and/or modify it under the terms of the GNU Affero)
10
+ [comment]: <> (General Public License as published by the Free)
11
+ [comment]: <> (Software Foundation, either version 3 of the License.)
12
+
13
+ [comment]: <> (This program is distributed in the hope that it will be)
14
+ [comment]: <> (useful, but WITHOUT ANY WARRANTY; without even the)
15
+ [comment]: <> (implied warranty of MERCHANTABILITY or FITNESS FOR)
16
+ [comment]: <> (A PARTICULAR PURPOSE. See the)
17
+ [comment]: <> (See the GNU Affero General Public License for)
18
+ [comment]: <> (more details.)
19
+
20
+ [comment]: <> (You should have received a copy of the GNU Affero)
21
+ [comment]: <> (General Public License along with this program.)
22
+ [comment]: <> (If not, see <https://www.gnu.org/licenses/>.)
23
+
24
+ # EVM Transactions Tools
25
+
26
+ A collection of useful Bash and JavaScript
27
+ programs and libraries to interact with
28
+ Ethereum Virtual Machine (EVM) networks transactions
29
+ in native computer applications, in particular those
30
+ written using the
31
+ [LibEVM](
32
+ https://github.com/themartiancompany/libevm)
33
+ and using the
34
+ [EVM Contracts Tools](
35
+ https://github.com).
36
+
37
+ Same as those, the tools obtains networks'
38
+ informations from the
39
+ [EVM Chains Info](
40
+ https://github.com/themartiancompany/evm-chains-info)
41
+ and
42
+ [EVM Chains Explorers](
43
+ https://github.com/themartiancompany/evm-chains-explorers)
44
+ programs.
45
+
46
+ The `evm-transaction-get` program uses the
47
+ [Ethers](
48
+ https://github.com/ethers-io/ethers.js)
49
+ JavaScript library to
50
+ interact with Ethereum Virtual Machine-compatible
51
+ blockchain networks and integrates natively with
52
+ and depends on the
53
+ [EVM Wallet](
54
+ https://github.com/themartiancompany/evm-wallet),
55
+ but it's also possible to directly provide seeds files.
56
+
57
+ The tools are a required software dependency for the
58
+ [EVM Contracts Source Index](
59
+ https://github.com/themartiancompany/evm-contracts-source-index).
60
+
61
+ ## Installation
62
+
63
+ The tools in this source repo
64
+ can be installed from source using GNU Make.
65
+
66
+ ```bash
67
+ make \
68
+ install
69
+ ```
70
+
71
+ The collection has been officially published
72
+ on the the uncensorable
73
+ [Ur](
74
+ https://github.com/themartiancompany/ur)
75
+ user repository and application store as
76
+ `evm-transactions-tools`.
77
+ The source code is published on the
78
+ [Ethereum Virtual Machine File System](
79
+ https://github.com/themartiancompany/evmfs)
80
+ so it can't possibly be taken down.
81
+
82
+ To install it from there just type
83
+
84
+ ```bash
85
+ ur \
86
+ evm-transactions-tools
87
+ ```
88
+
89
+ A censorable HTTP Github mirror of the recipe published there,
90
+ containing a full list of the software dependencies needed to run the
91
+ tools is hosted on
92
+ [evm-transactions-tools-ur](
93
+ https://github.com/themartiancompany/evm-contracts-tools-ur).
94
+
95
+ Be aware the mirror could go offline any time as Github and more
96
+ in general all HTTP resources are inherently unstable and censorable.
97
+
98
+ ## License
99
+
100
+ This program is released by Pellegrino Prevete under the terms
101
+ of the GNU Affero General Public License version 3.
@@ -0,0 +1,461 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** -----------------------------------------------------
6
+ * transaction-get
7
+ * -----------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * -----------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute
16
+ * it and/or modify it under the terms of the
17
+ * GNU General Public License as published by
18
+ * the Free Software Foundation, either version 3 of
19
+ * the License, or (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it
22
+ * will be useful, but WITHOUT ANY WARRANTY;
23
+ * without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25
+ * See the GNU General Public License
26
+ * for more details.
27
+ *
28
+ * You should have received a copy of the
29
+ * GNU General Public License
30
+ * along with this program.
31
+ * If not, see <https://www.gnu.org/licenses/>.
32
+ */
33
+
34
+
35
+ // const
36
+ // { ethers } =
37
+ // require(
38
+ // "ethers");
39
+ // _ethers =
40
+ // ethers;
41
+ const
42
+ _libcrash =
43
+ require(
44
+ '../libcrash-js/crash-js');
45
+ _cmdline_check =
46
+ _libcrash._cmdline_check;
47
+ _dirname =
48
+ _libcrash._dirname;
49
+ _file_read =
50
+ _libcrash._file_read;
51
+ _file_write =
52
+ _libcrash._file_write;
53
+ _json_display =
54
+ _libcrash._json_display;
55
+ _path_join =
56
+ _libcrash._path_join;
57
+ _msg_info =
58
+ _libcrash._msg_info;
59
+ _msg_error =
60
+ _libcrash._msg_error;
61
+ _printf =
62
+ _libcrash._printf;
63
+ const
64
+ _evm_wallet_get =
65
+ require(
66
+ '../evm-wallet/wallet-get');
67
+ _wallet_get =
68
+ _evm_wallet_get._wallet_get;
69
+ const
70
+ _network_provider_module =
71
+ require(
72
+ '../evm-wallet/network-provider');
73
+ _provider_get =
74
+ _network_provider_module._provider_get;
75
+
76
+ function
77
+ _global_variables() {
78
+ app_name =
79
+ "transaction-get"
80
+ retries_max =
81
+ "";
82
+ wallet_seed =
83
+ "";
84
+ wallet_password_path =
85
+ "";
86
+ transaction_address =
87
+ "";
88
+ chain_id =
89
+ "";
90
+ chain_name =
91
+ "";
92
+ target_network =
93
+ "";
94
+ api_key_path =
95
+ "";
96
+ output_path =
97
+ "";
98
+ quiet =
99
+ "";
100
+ }
101
+
102
+ function
103
+ _msg_error_no_input_data() {
104
+ let
105
+ _msg,
106
+ _text;
107
+ _text = [
108
+ "You need to provide either",
109
+ "the bytecode or the data"
110
+ ];
111
+ _msg =
112
+ _text.join(
113
+ " ");
114
+ _msg_error(
115
+ _msg,
116
+ 1);
117
+ }
118
+
119
+ function
120
+ _msg_info_wallet_selected(
121
+ _wallet) {
122
+ let
123
+ _msg,
124
+ _template;
125
+ _template =
126
+ "Wallet is '{_wallet}'.";
127
+ _msg =
128
+ _template.replaceAll(
129
+ "{_wallet}",
130
+ _wallet);
131
+ _msg_info(
132
+ _msg);
133
+ }
134
+
135
+ async function
136
+ _transaction_get(
137
+ _retries_max,
138
+ _wallet_seed,
139
+ _wallet_password_path,
140
+ _chain_id,
141
+ _chain_name,
142
+ _target_network,
143
+ _api_key_path,
144
+ _output_path,
145
+ _transaction_address) {
146
+ let
147
+ _api_key,
148
+ _get_transaction_opts,
149
+ _network,
150
+ _network_provider,
151
+ _provider_get_opts,
152
+ _tx,
153
+ _wallet,
154
+ _wallet_get_opts,
155
+ _wallet_path_list,
156
+ _wallet_path;
157
+ _provider_get_opts = [
158
+ _target_network
159
+ ];
160
+ if ( _output_path == undefined ) {
161
+ _output_path =
162
+ "";
163
+ }
164
+ if ( _api_key_path != "" ) {
165
+ _api_key =
166
+ _file_read(
167
+ _api_key_path);
168
+ }
169
+ else if ( _api_key_path == undefined ) {
170
+ _api_key =
171
+ "";
172
+ }
173
+ _provider_get_opts.push(
174
+ _api_key);
175
+ if ( _chain_id == undefined ) {
176
+ _chain_id =
177
+ "";
178
+ }
179
+ _provider_get_opts.push(
180
+ _chain_id);
181
+ if ( _chain_name == undefined ) {
182
+ _chain_name =
183
+ "";
184
+ }
185
+ _provider_get_opts.push(
186
+ _chain_name);
187
+ _network_provider =
188
+ await _provider_get.apply(
189
+ null,
190
+ _provider_get_opts);
191
+ if ( _wallet_seed != "" &&
192
+ _wallet_seed != undefined ) {
193
+ _wallet_path_list = [
194
+ _dirname(
195
+ _wallet_seed),
196
+ "wallet.dat"
197
+ ];
198
+ _wallet_path =
199
+ _path_join(
200
+ _wallet_path_list);
201
+ _wallet_get_opts = [
202
+ _wallet_path,
203
+ _wallet_password_path,
204
+ _wallet_seed,
205
+ _network_provider
206
+ ];
207
+ _wallet =
208
+ _wallet_get.apply(
209
+ null,
210
+ _wallet_get_opts);
211
+ _msg_info_wallet_selected(
212
+ _wallet);
213
+ _network_provider =
214
+ _wallet;
215
+ }
216
+ try {
217
+ _tx =
218
+ await _network_provider.getTransaction(
219
+ _transaction_address);
220
+ if ( _output_path != "" ) {
221
+ _json =
222
+ _json_display(
223
+ _tx);
224
+ _file_write(
225
+ _output_path,
226
+ _json);
227
+ }
228
+ } catch (e) {
229
+ console.error(
230
+ e);
231
+ }
232
+ return _tx;
233
+ }
234
+
235
+ function
236
+ _config_show() {
237
+ let
238
+ _line,
239
+ _text;
240
+ _text = [];
241
+ _text.push(
242
+ " Maximum retries: {retries_max}".replace(
243
+ "{retries_max}",
244
+ retries_max));
245
+ _text.push(
246
+ " Wallet seed: {wallet_seed}".replace(
247
+ "{wallet_seed}",
248
+ wallet_seed));
249
+ _text.push(
250
+ " Chain ID: {chain_id}".replace(
251
+ "{chain_id}",
252
+ chain_id));
253
+ _text.push(
254
+ " Chain Name: {chain_name}".replace(
255
+ "{chain_name}",
256
+ chain_name));
257
+ _text.push(
258
+ " Target network: {target_network}".replace(
259
+ "{target_network}",
260
+ target_network));
261
+ _text.push(
262
+ " API Key: {api_key_path}".replace(
263
+ "{api_key_path}",
264
+ api_key_path));
265
+ _text.push(
266
+ " Output path: {output_path}".replace(
267
+ "{output_path}",
268
+ output_path));
269
+ _text.push(
270
+ " Transaction address: {transaction_address}".replace(
271
+ "{transaction_address}",
272
+ transaction_address));
273
+ for ( _line of _text ) {
274
+ _msg_info(
275
+ _line);
276
+ }
277
+ }
278
+
279
+ function
280
+ _usage(
281
+ _exit_code) {
282
+ let
283
+ _line,
284
+ _text;
285
+ _text = [
286
+ "Usage:",
287
+ " contract-get",
288
+ " <quiet>",
289
+ " <retries_max>",
290
+ " <wallet_seed>",
291
+ " <wallet_password_path>",
292
+ " <chain_id>",
293
+ " <chain_name>",
294
+ " <target_network>",
295
+ " <api_key_path>",
296
+ " <output_path>",
297
+ " <transaction_address>",
298
+ "",
299
+ "Args:",
300
+ " <quiet> Can be 'y' or 'n'",
301
+ " Default: y",
302
+ " <retries_max> Maximum number of retries before",
303
+ " failing.",
304
+ " <wallet_seed> Path of the seed phrase.",
305
+ " <wallet_password_path> Wallet password path.",
306
+ " <chain_id> Chain ID for the network.",
307
+ " <chain_name> Name for the network.",
308
+ " <target_network> Network on which the transaction",
309
+ " resides.",
310
+ " <api_key_path> Path of the API key for the",
311
+ " network provider service.",
312
+ " <output_path> File on which to optionally save",
313
+ " the output.",
314
+ " <transaction_address> Transaction one wants to retrieve.",
315
+ "",
316
+ " Options:",
317
+ " -h This help."
318
+ ];
319
+ for ( _line of _text ) {
320
+ _msg_info(
321
+ _line);
322
+ }
323
+ process.exit(
324
+ _exit_code);
325
+ }
326
+
327
+ function _cmdline_parse() {
328
+ quiet =
329
+ "y";
330
+ process.argv.forEach(
331
+ function (
332
+ _value,
333
+ _index,
334
+ _array) {
335
+ if ( _index == 2 ) {
336
+ quiet =
337
+ _value;
338
+ }
339
+ if ( _index == 3 ) {
340
+ retries_max =
341
+ _value;
342
+ }
343
+ if ( _index == 4 ) {
344
+ wallet_seed =
345
+ _value;
346
+ }
347
+ if ( _index == 5 ) {
348
+ wallet_password_path =
349
+ _value;
350
+ }
351
+ if ( _index == 6 ) {
352
+ chain_id =
353
+ _value;
354
+ }
355
+ if ( _index == 7 ) {
356
+ chain_name =
357
+ _value;
358
+ }
359
+ if ( _index == 8 ) {
360
+ target_network =
361
+ _value;
362
+ }
363
+ if ( _index == 9 ) {
364
+ api_key_path =
365
+ _value;
366
+ }
367
+ if ( _index == 10 ) {
368
+ output_path =
369
+ _value;
370
+ }
371
+ if ( _index == 11 ) {
372
+ transaction_address =
373
+ _value;
374
+ }
375
+ if ( _value == "-h" ||
376
+ _value == "--help" ) {
377
+ quiet =
378
+ "n";
379
+ _usage(
380
+ 0);
381
+ }
382
+ }
383
+ );
384
+ if ( transaction_address == "" ) {
385
+ quiet =
386
+ "n";
387
+ _usage(
388
+ 1);
389
+ }
390
+ }
391
+
392
+ function
393
+ _overrides_set() {
394
+ if ( retries_max == "" ) {
395
+ retries_max =
396
+ 100;
397
+ }
398
+ if ( chain_id == "" ) {
399
+ _msg_info(
400
+ "TODO: use evm_chains_info_module");
401
+ }
402
+ if ( chain_name == "" ) {
403
+ _msg_info(
404
+ "TODO: use evm_chains_info_module");
405
+ }
406
+ }
407
+
408
+ async function
409
+ _transaction_get_cmdline(
410
+ _app_opts) {
411
+ let
412
+ _json,
413
+ _tx;
414
+ try {
415
+ _tx =
416
+ await _transaction_get.apply(
417
+ null,
418
+ _app_opts);
419
+ if ( _tx != undefined ) {
420
+ _json =
421
+ _json_display(
422
+ _tx);
423
+ _printf(
424
+ _json);
425
+ }
426
+ else {
427
+ throw "Transaction Get returned undefined value."
428
+ }
429
+ } catch (error) {
430
+ _msg_error(
431
+ error,
432
+ 1);
433
+ }
434
+ }
435
+
436
+
437
+ if ( _cmdline_check(
438
+ "transaction-get") ) {
439
+ _global_variables();
440
+ _cmdline_parse();
441
+ _overrides_set();
442
+ _config_show();
443
+ app_opts = [
444
+ retries_max,
445
+ wallet_seed,
446
+ wallet_password_path,
447
+ chain_id,
448
+ chain_name,
449
+ target_network,
450
+ api_key_path,
451
+ output_path,
452
+ transaction_address
453
+ ];
454
+ _transaction_get_cmdline(
455
+ app_opts);
456
+ }
457
+
458
+ module.exports = {
459
+ _transaction_get:
460
+ _transaction_get
461
+ };