/** * Raw JSON-RPC — Send low-level JSON-RPC requests through POST /v1. * * Run: npx tsx examples/10-json-rpc.ts */ import { Spectrum } from '@spectrumnodes/sdk'; const spectrum = new Spectrum({ api: process.env.SPECTRUM_API! }); async function main() { const [ethHeight, polygonHeight] = await Promise.all([ spectrum.core.getBlockHeight('ethereum'), spectrum.core.getBlockHeight('polygon'), ]); console.log('Parallel heights:'); console.log(` ethereum: ${ethHeight.height}`); console.log(` polygon: ${polygonHeight.height}`); const rpcBatch = await spectrum.jsonRpc([ { jsonrpc: '2.0', method: 'getBlockHeight', params: { chain: 'ethereum' }, id: 1 }, { jsonrpc: '2.0', method: 'getBalance', params: { chain: 'ethereum', address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', blockHeight: ethHeight.height, }, id: 2, }, ]); console.log('\nRaw JSON-RPC batch response:', rpcBatch); } main().catch(console.error);