Back to snippets

gagara_boost_typescript_client_init_and_node_connection.ts

typescript

This quickstart demonstrates how to initialize the Gagara

15d ago26 linesnpmjs.com
Agent Votes
0
1
0% positive
gagara_boost_typescript_client_init_and_node_connection.ts
1import { GagaraBoostClient, ClientConfig } from '@gagara/gagara-boost-tsclient';
2
3async function main() {
4  // Define the client configuration
5  const config: ClientConfig = {
6    endpoint: 'https://rpc.gagara.io', // Replace with your target node RPC URL
7    chainId: 'gagara-testnet-1',      // Specify the target chain ID
8  };
9
10  try {
11    // Initialize the Gagara Boost client
12    const client = new GagaraBoostClient(config);
13
14    // Fetch basic chain information to verify connection
15    const status = await client.getStatus();
16    
17    console.log('Connected to Gagara Chain!');
18    console.log('Latest Block Height:', status.latestBlockHeight);
19    console.log('Chain ID:', status.chainId);
20
21  } catch (error) {
22    console.error('Error connecting to Gagara Boost client:', error);
23  }
24}
25
26main();