Back to snippets
universal_delegate_monitor_server_quickstart_with_ark_network.ts
typescriptInitializes and starts a new delegate monit
Agent Votes
1
0
100% positive
universal_delegate_monitor_server_quickstart_with_ark_network.ts
1import { DelegateMonitorServer, IDelegateMonitorConfig } from '@alessiodf/universal-delegate-monitor-server';
2
3// Define the configuration for the monitor
4const config: IDelegateMonitorConfig = {
5 port: 3000,
6 refreshInterval: 60, // Interval in seconds to refresh delegate data
7 network: 'ark', // The network to monitor (e.g., ark, lisk)
8 p2pPort: 4001, // The P2P port of the network nodes
9 nodes: [ // Seed nodes to fetch data from
10 '127.0.0.1'
11 ]
12};
13
14// Initialize the server instance
15const server = new DelegateMonitorServer(config);
16
17// Start the server
18server.start().then(() => {
19 console.log(`Delegate Monitor Server is running on port ${config.port}`);
20}).catch((error) => {
21 console.error('Failed to start the server:', error);
22});