LCX Logo

    RPC API Reference

    Liberty Chain exposes a standard Ethereum JSON-RPC API. If you have worked with any EVM chain before, the same methods, request format, and client libraries all work here. This page covers the endpoint details, supported methods, and usage examples.

    Endpoint

    HTTPShttps://testnet-rpc.lcx.com
    WebSocketwss://testnet-rpc.lcx.com
    Chain ID76847801

    No API Key Required

    The public RPC endpoint does not require an API key. Rate limits apply to ensure fair usage across all developers.

    Supported Methods

    Liberty Chain supports the standard Ethereum JSON-RPC methods, plus OP Stack-specific methods for rollup status. The table below lists the most commonly used methods.

    Standard Ethereum Methods

    MethodDescription
    eth_blockNumberReturns the latest block number
    eth_getBalanceReturns the balance of an address in wei
    eth_getTransactionCountReturns the nonce for an address
    eth_sendRawTransactionSubmits a signed transaction to the network
    eth_callExecutes a read-only call against a contract
    eth_estimateGasEstimates the gas needed for a transaction
    eth_getTransactionReceiptReturns the receipt for a mined transaction
    eth_getBlockByNumberReturns block data by block number
    eth_getBlockByHashReturns block data by block hash
    eth_getLogsReturns logs matching a filter
    eth_getCodeReturns the bytecode at an address
    eth_gasPriceReturns the current gas price in wei
    eth_chainIdReturns the chain ID (76847801)
    net_versionReturns the network ID

    OP Stack-Specific Methods

    MethodDescription
    optimism_syncStatusReturns the current sync status of the node, including the latest L1 and L2 block references and their safety levels.
    optimism_outputAtBlockReturns the output root at a given L2 block number, used by the proposer and verifier for fault proofs.

    Usage Examples

    Get the Latest Block Number

    curl — eth_blockNumber
    bash
    curl -X POST https://testnet-rpc.lcx.com \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "method": "eth_blockNumber",
        "params": [],
        "id": 1
      }'
    Response
    json
    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": "0x1a4b2"
    }

    Get Account Balance

    curl — eth_getBalance
    bash
    curl -X POST https://testnet-rpc.lcx.com \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "method": "eth_getBalance",
        "params": ["0xYOUR_ADDRESS_HERE", "latest"],
        "id": 1
      }'

    Estimate Gas

    curl — eth_estimateGas
    bash
    curl -X POST https://testnet-rpc.lcx.com \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "method": "eth_estimateGas",
        "params": [{
          "from": "0xSENDER_ADDRESS",
          "to": "0xRECIPIENT_ADDRESS",
          "value": "0xde0b6b3a7640000"
        }],
        "id": 1
      }'

    Send a Raw Transaction

    curl — eth_sendRawTransaction
    bash
    curl -X POST https://testnet-rpc.lcx.com \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "method": "eth_sendRawTransaction",
        "params": ["0xSIGNED_TRANSACTION_DATA"],
        "id": 1
      }'

    Using ethers.js

    ethers.js example
    javascript
    import { ethers } from "ethers";
    
    const provider = new ethers.JsonRpcProvider(
      "https://testnet-rpc.lcx.com"
    );
    
    // Get latest block number
    const blockNumber = await provider.getBlockNumber();
    console.log("Latest block:", blockNumber);
    
    // Get balance
    const balance = await provider.getBalance("0xYOUR_ADDRESS");
    console.log("Balance:", ethers.formatEther(balance), "ETH");
    
    // Get gas price
    const feeData = await provider.getFeeData();
    console.log("Gas price:", ethers.formatUnits(feeData.gasPrice, "gwei"), "gwei");

    WebSocket Subscriptions

    For real-time data such as new blocks, pending transactions, or event logs, use the WebSocket endpoint. WebSocket connections support the eth_subscribe method for push-based notifications.

    WebSocket subscription
    javascript
    import { ethers } from "ethers";
    
    const wsProvider = new ethers.WebSocketProvider(
      "wss://testnet-rpc.lcx.com"
    );
    
    // Subscribe to new blocks
    wsProvider.on("block", (blockNumber) => {
      console.log("New block:", blockNumber);
    });
    
    // Subscribe to contract events
    const contract = new ethers.Contract(contractAddress, abi, wsProvider);
    contract.on("Transfer", (from, to, value) => {
      console.log(`Transfer: ${from} -> ${to}: ${value}`);
    });

    Rate Limits

    The public RPC endpoint enforces rate limits to ensure fair access for all users. Current limits are:

    LimitValue
    Requests per second (per IP)25
    Batch request size20 calls per batch
    WebSocket connections (per IP)5
    eth_getLogs block range10,000 blocks

    Rate Limit Exceeded

    If you receive HTTP 429 responses, you are exceeding the rate limit. Implement exponential backoff in your application, or consider batching multiple calls into a single request to reduce your request count.

    For production applications that require higher throughput, contact the Liberty Chain team to discuss dedicated RPC access.