Skip to main content

Read the chain with viem

import { createPublicClient, http, defineChain } from 'viem';

export const khromosome = defineChain({
id: 777001,
name: 'Khromosome',
nativeCurrency: { name: 'KHROME', symbol: 'KHROME', decimals: 18 },
rpcUrls: { default: { http: ['https://rpc.khromosome.xyz'] } },
blockExplorers: {
default: { name: 'KHROME Explorer', url: 'https://explorer.khromosome.network' },
},
});

const client = createPublicClient({ chain: khromosome, transport: http() });

const block = await client.getBlockNumber();
console.log('latest block', block);

For live updates, use the WebSocket endpoint:

import { createPublicClient, webSocket } from 'viem';

const ws = createPublicClient({
chain: khromosome,
transport: webSocket('wss://ws.khromosome.xyz'),
});

const unwatch = ws.watchBlocks({ onBlock: (b) => console.log(b.number) });