/** * Getting Started — Initialize the SDK and make your first calls. * * Run: npx tsx examples/01-getting-started.ts */ import { Spectrum } from '@spectrumnodes/sdk'; const spectrum = new Spectrum({ api: process.env.SPECTRUM_API!, defaultChain: 'ethereum', }); async function main() { // Uses the configured default chain ('ethereum'). const block = await spectrum.core.getBlockHeight(); console.log(`Ethereum block height: ${block.height}`); // You can still override the chain per call. const polyBlock = await spectrum.core.getBlockHeight('polygon'); console.log(`Polygon block height: ${polyBlock.height}`); // Run multiple calls concurrently with Promise.all (fail-fast). const [ethBlock, solBlock] = await Promise.all([ spectrum.core.getBlockHeight('ethereum'), spectrum.core.getBlockHeight('solana'), ]); console.log(`ETH: ${ethBlock.height}, SOL: ${solBlock.height}`); // Utility namespace calls work the same way. const health = await spectrum.utils.health(); console.log(`API status: ${health.status}`); } main().catch(console.error);