Lux Docs

TypeScript SDK

TypeScript/JavaScript client library for Lux Network

The TypeScript SDK (@luxfi/sdk) provides a fully typed interface for building applications on Lux Network. It supports all chain types with native TypeScript types and works in both Node.js and browser environments.

Installation

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

Quick Start

import { LuxClient } from "@luxfi/sdk";

const client = new LuxClient({
  network: "mainnet",
  endpoint: "https://api.lux.network/mainnet",
});

// Get C-Chain block number
const block = await client.cChain.getBlockNumber();
console.log("Latest block:", block);

// Get balance
const balance = await client.cChain.getBalance(
  "0x9011E888251AB053B7bD1cdB598Db4f9DEd94714"
);
console.log("Balance:", balance, "wei");

Core Packages

PackagePurpose
@luxfi/sdkTop-level client for all chain operations
@luxfi/sdk/walletHD wallet with BIP-44 derivation
@luxfi/sdk/rpcTyped JSON-RPC client
@luxfi/sdk/contractsSmart contract interaction helpers
@luxfi/sdk/typesTypeScript type definitions

Chain Support

ChainRPCTransactionsContracts
P-ChainYesYesN/A
X-ChainYesYesN/A
C-ChainYesYesYes
Subnet EVMYesYesYes

Framework Integration

The SDK works with popular Web3 libraries:

import { createPublicClient, http } from "viem";

const client = createPublicClient({
  chain: {
    id: 96369,
    name: "Lux",
    nativeCurrency: { name: "LUX", symbol: "LUX", decimals: 18 },
    rpcUrls: {
      default: {
        http: ["https://api.lux.network/mainnet/ext/bc/C/rpc"],
      },
    },
  },
  transport: http(),
});

const blockNumber = await client.getBlockNumber();

On this page