jaelis-node 2.0.0 → 2.1.0

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 CHANGED
@@ -16,6 +16,17 @@ Official external node software for the **JAELIS Blockchain** network. Run your
16
16
 
17
17
  This is similar to running `geth --syncmode light` for Ethereum.
18
18
 
19
+ ## AI Agent Quick Start
20
+
21
+ Get a named node running in 2 commands:
22
+
23
+ ```bash
24
+ npm install -g jaelis-node
25
+ jaelis-node --name "MY-AGENT" --network testnet
26
+ ```
27
+
28
+ Your agent node will sync with the JAELIS testnet, expose a local RPC at `http://localhost:8545`, and persist its name across restarts.
29
+
19
30
  ## Quick Start
20
31
 
21
32
  ### Install Globally
@@ -33,6 +44,9 @@ jaelis-node
33
44
  # Start on mainnet
34
45
  jaelis-node --network mainnet
35
46
 
47
+ # Name your node (persists across restarts)
48
+ jaelis-node --name MARBIT
49
+
36
50
  # Custom RPC port
37
51
  jaelis-node --port 8546
38
52
 
@@ -80,6 +94,7 @@ const balance = await jaelis.getBalance('jae1qwertyuiop...'); // JAELIS native a
80
94
  | `-n, --network <network>` | Network to connect to (`testnet` or `mainnet`) | `testnet` |
81
95
  | `-p, --port <port>` | Local RPC server port | `8545` |
82
96
  | `-d, --data-dir <dir>` | Data directory for block storage | `./jaelis-data/<network>` |
97
+ | `--name <name>` | Custom node name (e.g., `MARBIT`, `my-agent`) | Auto-generated ID |
83
98
  | `--no-rpc` | Disable local RPC server | Enabled |
84
99
 
85
100
  ## Programmatic Usage
@@ -92,6 +107,7 @@ async function main() {
92
107
  network: 'testnet',
93
108
  rpcPort: 8545,
94
109
  dataDir: './my-jaelis-data',
110
+ nodeName: 'MY-AGENT', // Name your node
95
111
  enableRpc: true
96
112
  });
97
113
 
@@ -10,8 +10,9 @@
10
10
  * jaelis-node --network mainnet # Start on mainnet
11
11
  * jaelis-node --port 8546 # Custom RPC port
12
12
  * jaelis-node --data-dir ./mydata # Custom data directory
13
+ * jaelis-node --name MARBIT # Name your node
13
14
  *
14
- * @version 2.0.0
15
+ * @version 2.1.0
15
16
  */
16
17
 
17
18
  'use strict';
@@ -20,7 +21,7 @@ const { Command } = require('commander');
20
21
  const { JaelisNode } = require('../lib/node');
21
22
 
22
23
  // Version check - notify if update available
23
- const VERSION = '2.0.0';
24
+ const VERSION = '2.1.0';
24
25
  checkForUpdates();
25
26
 
26
27
  // CLI setup
@@ -33,6 +34,7 @@ program
33
34
  .option('-n, --network <network>', 'Network to connect to (testnet or mainnet)', 'testnet')
34
35
  .option('-p, --port <port>', 'Local RPC port', '8545')
35
36
  .option('-d, --data-dir <dir>', 'Data directory for local storage')
37
+ .option('--name <name>', 'Custom node name (e.g., MARBIT, my-agent)')
36
38
  .option('--no-rpc', 'Disable local RPC server')
37
39
  .parse(process.argv);
38
40
 
@@ -44,6 +46,7 @@ async function main() {
44
46
  network: options.network,
45
47
  rpcPort: parseInt(options.port, 10),
46
48
  dataDir: options.dataDir,
49
+ nodeName: options.name || null,
47
50
  enableRpc: options.rpc !== false
48
51
  });
49
52
 
@@ -66,7 +69,8 @@ async function main() {
66
69
  // Print status every 30 seconds
67
70
  setInterval(() => {
68
71
  const status = node.getStatus();
69
- console.log(`[STATUS] Block: ${status.currentBlock} | Uptime: ${status.uptimeFormatted} | RPC Requests: ${status.stats.rpcRequests}`);
72
+ const nameTag = status.nodeName ? `${status.nodeName} | ` : '';
73
+ console.log(`[STATUS] ${nameTag}Block: ${status.currentBlock} | Uptime: ${status.uptimeFormatted} | RPC Requests: ${status.stats.rpcRequests}`);
70
74
  }, 30000);
71
75
 
72
76
  } catch (error) {
package/lib/node.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Does NOT contain any internal JAELIS blockchain code.
6
6
  * Only implements the network protocol for syncing and RPC.
7
7
  *
8
- * @version 2.0.0
8
+ * @version 2.1.0
9
9
  */
10
10
 
11
11
  'use strict';
@@ -41,6 +41,7 @@ class JaelisNode extends EventEmitter {
41
41
  * @param {string} options.dataDir - Data directory for local storage
42
42
  * @param {number} options.rpcPort - Local RPC port (default: 8545)
43
43
  * @param {boolean} options.enableRpc - Enable local RPC server (default: true)
44
+ * @param {string} options.nodeName - Custom node name (e.g., 'MARBIT')
44
45
  */
45
46
  constructor(options = {}) {
46
47
  super();
@@ -56,8 +57,9 @@ class JaelisNode extends EventEmitter {
56
57
  this.rpcPort = options.rpcPort || 8545;
57
58
  this.enableRpc = options.enableRpc !== false;
58
59
 
59
- // Node state
60
+ // Node identity
60
61
  this.nodeId = this._generateNodeId();
62
+ this.nodeName = options.nodeName || this._loadNodeName();
61
63
  this.startTime = null;
62
64
  this.isRunning = false;
63
65
  this.isSyncing = false;
@@ -84,6 +86,35 @@ class JaelisNode extends EventEmitter {
84
86
  return 'jaelis_' + crypto.randomBytes(8).toString('hex');
85
87
  }
86
88
 
89
+ /**
90
+ * Load persisted node name from data directory
91
+ */
92
+ _loadNodeName() {
93
+ try {
94
+ const fs = require('fs');
95
+ const path = require('path');
96
+ const nameFile = path.join(this.dataDir, 'node-name.json');
97
+ const data = JSON.parse(fs.readFileSync(nameFile, 'utf8'));
98
+ return data.name || null;
99
+ } catch (e) {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Persist node name to data directory
106
+ */
107
+ _saveNodeName() {
108
+ if (!this.nodeName) return;
109
+ try {
110
+ const fs = require('fs');
111
+ const path = require('path');
112
+ fs.mkdirSync(this.dataDir, { recursive: true });
113
+ const nameFile = path.join(this.dataDir, 'node-name.json');
114
+ fs.writeFileSync(nameFile, JSON.stringify({ name: this.nodeName, setAt: Date.now() }));
115
+ } catch (e) {}
116
+ }
117
+
87
118
  /**
88
119
  * Start the node
89
120
  */
@@ -92,10 +123,16 @@ class JaelisNode extends EventEmitter {
92
123
  throw new Error('Node is already running');
93
124
  }
94
125
 
126
+ // Persist node name if provided
127
+ this._saveNodeName();
128
+
95
129
  console.log('');
96
130
  console.log('═══════════════════════════════════════════════════════════════');
97
- console.log(' JAELIS EXTERNAL NODE v2.0.0');
131
+ console.log(' JAELIS EXTERNAL NODE v2.1.0');
98
132
  console.log('═══════════════════════════════════════════════════════════════');
133
+ if (this.nodeName) {
134
+ console.log(` Node Name: ${this.nodeName}`);
135
+ }
99
136
  console.log(` Network: ${this.networkConfig.name}`);
100
137
  console.log(` Chain ID: ${this.networkConfig.chainId}`);
101
138
  console.log(` Node ID: ${this.nodeId}`);
@@ -215,6 +252,7 @@ class JaelisNode extends EventEmitter {
215
252
 
216
253
  return {
217
254
  nodeId: this.nodeId,
255
+ nodeName: this.nodeName || null,
218
256
  network: this.network,
219
257
  chainId: this.networkConfig.chainId,
220
258
  isRunning: this.isRunning,
@@ -223,7 +261,7 @@ class JaelisNode extends EventEmitter {
223
261
  uptimeFormatted: this._formatUptime(uptime),
224
262
  currentBlock: this.storage?.getLatestBlockNumber() || 0,
225
263
  stats: this.stats,
226
- version: '2.0.0',
264
+ version: '2.1.0',
227
265
  rpcPort: this.enableRpc ? this.rpcPort : null
228
266
  };
229
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaelis-node",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Official JAELIS Blockchain External Node - Connect to the JAELIS network, sync blocks, and expose local RPC for your dApps. Zero gas fees, multi-chain interop.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {