Lux Docs

RPC Operations

JSON-RPC calls to Lux nodes using the TypeScript SDK

The TypeScript SDK provides typed access to all Lux node JSON-RPC endpoints. For EVM chains, it integrates with viem and ethers.js.

C-Chain RPC with viem

import { createPublicClient, http, formatEther } from "viem";

const client = createPublicClient({
  transport: http(
    "https://api.lux.network/mainnet/ext/bc/C/rpc"
  ),
});

// Get latest block
const block = await client.getBlock();
console.log("Block:", block.number);

// Get balance
const balance = await client.getBalance({
  address: "0x9011E888251AB053B7bD1cdB598Db4f9DEd94714",
});
console.log("Balance:", formatEther(balance), "LUX");

// Get gas price
const gasPrice = await client.getGasPrice();
console.log("Gas price:", gasPrice);

C-Chain RPC with ethers.js

import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider(
  "https://api.lux.network/mainnet/ext/bc/C/rpc"
);

const block = await provider.getBlockNumber();
const balance = await provider.getBalance(
  "0x9011E888251AB053B7bD1cdB598Db4f9DEd94714"
);
console.log("Block:", block, "Balance:", ethers.formatEther(balance));

P-Chain RPC

const response = await fetch(
  "https://api.lux.network/mainnet/ext/bc/P",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      jsonrpc: "2.0",
      method: "platform.getCurrentValidators",
      params: {},
      id: 1,
    }),
  }
);

const { result } = await response.json();
console.log("Validators:", result.validators.length);

Subnet EVM RPC

All Subnet EVM chains use the same interface -- change the endpoint URL:

// Zoo chain
const zoo = createPublicClient({
  transport: http(
    "https://api.lux.network/mainnet/ext/bc/zoo/rpc"
  ),
});

// Hanzo chain
const hanzo = createPublicClient({
  transport: http(
    "https://api.lux.network/mainnet/ext/bc/hanzo/rpc"
  ),
});

Network Endpoints

NetworkC-Chain RPC URL
Mainnethttps://api.lux.network/mainnet/ext/bc/C/rpc
Testnethttps://api.lux.network/testnet/ext/bc/C/rpc
Localhttp://127.0.0.1:9630/ext/bc/C/rpc

Chain IDs

ChainMainnetTestnet
C-Chain9636996368
Zoo200200200201
Hanzo3696336964
SPC3691136910
Pars494949494950

On this page