@lithosphere/sdk

High-level TypeScript client for the Lithosphere chain.

pnpm add @lithosphere/sdk
# or
npm install @lithosphere/sdk

Quickstart

import { LithoClient, NETWORKS, LithoError, ErrorCode } from '@lithosphere/sdk';

const client = new LithoClient('mainnet');

const height = await client.getBlockNumber();
const { formatted } = await client.getBalance('0x22d279d24f0b7ca5d49c5a7a7f032da416f72387');
console.log(`Head block: ${height}, balance: ${formatted} LITHO`);

Error handling

Every failure path throws a LithoError with a typed code:

try {
  await client.getBalance('0xnot-a-real-address');
} catch (err) {
  if (err instanceof LithoError && err.code === ErrorCode.INVALID_ADDRESS) {
    // user input is bad — surface a friendly message
  }
}

Retry / backoff

The client retries on transient failures (network errors, 5xx, 429) with exponential backoff. Defaults: 3 retries, base delay 250ms, exponentially doubled per attempt. Tune via the constructor:

Contract calls

Pair with viem (or ethers) and the ABIs from @lithosphere/blockchain-core:

Network registry

See docs/api-reference/sdk-reference.md for the full API.

Last updated