Solana

Solana Beta is live. Try BoltRPC Solana endpoints free - start your trial now.

X Layer RPC Guide: Endpoints, Methods, Code Examples 2026

Complete X Layer RPC guide covering public endpoints, ethers.js, Web3.py, curl examples, OKX zkEVM architecture, ZK proof finality, production patterns.

BoltRPC
BoltRPC Team
11 min read
X Layer RPC Guide: Endpoints, Methods, Code Examples 2026

X Layer RPC Guide: Endpoints, OKX zkEVM, Production Patterns (2026)

X Layer is OKX’s layer-2 blockchain built on Polygon CDK’s zkEVM technology. It settles to Ethereum via ZK proof verification, inheriting Ethereum’s security guarantees while offering lower fees and faster throughput. The network is designed for OKX ecosystem integrations, including OKX DEX, OKX Web3 wallet, a growing DeFi ecosystem that benefits from deep exchange liquidity.

This guide covers public X Layer RPC endpoints, multi-library connection examples, ZK proof finality mechanics, the specific production considerations for building on an exchange-native L2.

For BoltRPC endpoint setup and MetaMask configuration, see the X Layer chain page.


X Layer Architecture: OKX zkEVM on Polygon CDK

X Layer uses Polygon CDK’s Type 2 zkEVM implementation. Key architectural points that affect your RPC usage:

ZK proof finality is different from optimistic rollup finality. Unlike Arbitrum or Optimism (which use fraud proofs with 7-day withdrawal windows), X Layer uses ZK proofs. Once a batch is proven on Ethereum, it is final with no challenge period. This creates a different confirmation flow: fast sequencer confirmation (seconds), followed by ZK proof generation (minutes to hours), followed by Ethereum L1 finality (once the proof batch is verified on-chain).

Three confirmation stages. An X Layer transaction moves through: (1) sequencer acceptance, where the transaction is included in an L2 batch; (2) ZK proof generation, where the batch is proven off-chain; (3) L1 verification, where the proof is submitted and verified on Ethereum. The eth_getTransactionReceipt status becomes 1 at the sequencer stage. Full L1 finality requires waiting for stage 3.

Full EVM compatibility. X Layer supports all standard Ethereum JSON-RPC methods. Any Solidity contract, ethers.js code, or Web3.py script written for Ethereum works on X Layer.

OKB as native token. The native gas token is OKB (OKX’s native token). Unlike ETH-based L2s where you hold ETH for gas, X Layer requires OKB. This affects wallet setup, faucet access, exchange integration design.

Exchange-native traffic patterns. X Layer sees traffic bursts correlated with OKX exchange activity: market events, token listings, trading competitions. Public RPC endpoints can become congested during these periods. Dedicated infrastructure handles this better than shared public nodes.


Public X Layer RPC Endpoints

ProviderHTTP EndpointWSS EndpointNotes
OKX (official)https://rpc.xlayer.techwss://xlayerws.okx.comOfficial, can bottleneck during exchange events
Chainstackhttps://xlayer-mainnet.core.chainstack.comnonePaid tiers available
dRPChttps://xlayer.drpc.orgnonePublic tier available

Chain ID: 196 Native token: OKB Block explorer: https://www.oklink.com/xlayer

For production, use BoltRPC: https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY


Connecting to X Layer

ethers.js

import { ethers } from "ethers";

// HTTP provider
const provider = new ethers.JsonRpcProvider(
  "https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY"
);

// Verify chain ID (should be 196)
const network = await provider.getNetwork();
console.log("Chain ID:", network.chainId); // 196n

// Get latest block
const blockNumber = await provider.getBlockNumber();
console.log("X Layer block:", blockNumber);

// Read OKB balance (native token, 18 decimals, same as ETH)
const balance = await provider.getBalance("0xYourAddress");
console.log("OKB balance:", ethers.formatEther(balance));

// Call a contract
const abi = ["function balanceOf(address) view returns (uint256)"];
const token = new ethers.Contract("0xTokenAddress", abi, provider);
const tokenBalance = await token.balanceOf("0xYourAddress");
console.log("Token balance:", ethers.formatUnits(tokenBalance, 18));

Web3.py

from web3 import Web3

# Connect to X Layer
w3 = Web3(Web3.HTTPProvider(
    "https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY"
))

print("Connected:", w3.is_connected())
print("Chain ID:", w3.eth.chain_id)  # 196

# Guard: confirm X Layer
assert w3.eth.chain_id == 196, f"Wrong chain: {w3.eth.chain_id}"

# Get gas price
gas_price = w3.eth.gas_price
print("Gas price (gwei):", Web3.from_wei(gas_price, "gwei"))

# Read block
block = w3.eth.get_block("latest")
print("Block:", block["number"], "| Timestamp:", block["timestamp"])

# Send signed transaction example
# (sign offline, never expose private keys in production)
signed_tx = w3.eth.account.sign_transaction(
    {"nonce": w3.eth.get_transaction_count("0xYourAddress"),
     "gasPrice": gas_price,
     "gas": 21000,
     "to": "0xRecipient",
     "value": Web3.to_wei(0.001, "ether"),
     "chainId": 196},
    private_key="0xYourPrivateKey"
)
tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
print("TX hash:", tx_hash.hex())

curl

# Get chain ID (X Layer = 0xc4 = 196)
curl https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY \
  -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'

# Get block number
curl https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY \
  -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

# Estimate gas for a transaction
curl https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY \
  -X POST -H "Content-Type: application/json" \
  --data '{
    "jsonrpc":"2.0",
    "method":"eth_estimateGas",
    "params":[{
      "from": "0xYourAddress",
      "to": "0xContractAddress",
      "data": "0xYourCalldata"
    }],
    "id":1
  }'

# Get transaction receipt: check status and confirmations
curl https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY \
  -X POST -H "Content-Type: application/json" \
  --data '{
    "jsonrpc":"2.0",
    "method":"eth_getTransactionReceipt",
    "params":["0xYourTxHash"],
    "id":1
  }'

WebSocket subscription

import { ethers } from "ethers";

const wsProvider = new ethers.WebSocketProvider(
  "wss://eu.endpoints.matrixed.link/ws/xlayer?auth=YOUR_KEY"
);

// Subscribe to new blocks
wsProvider.on("block", (blockNumber) => {
  console.log("New X Layer block:", blockNumber);
});

// Subscribe to contract events
const abi = ["event Swap(address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to)"];
const contract = new ethers.Contract("0xDEXContract", abi, wsProvider);

contract.on("Swap", (sender, a0in, a1in, a0out, a1out, to, event) => {
  console.log("Swap on X Layer:", event.log.transactionHash);
});

Example X Layer RPC Methods

X Layer supports all standard Ethereum JSON-RPC methods. Code examples are for reference. Verify against the official X Layer documentation before production use.

MethodPurposeX Layer Notes
eth_chainIdReturns 0xc4 (196)Use to verify X Layer connection
eth_blockNumberGet current block height~3 second block time
eth_callRead contract stateStandard EVM
eth_estimateGasEstimate gas costLower fees than Ethereum
eth_sendRawTransactionBroadcast transactionOKB required for gas
eth_getTransactionReceiptGet transaction resultStatus 1 = sequencer confirmed
eth_getLogsFetch contract eventsStandard filter params
eth_gasPriceCurrent gas price in weiSignificantly lower than Ethereum

ZK Proof Finality: What It Means for Your Application

X Layer uses ZK proofs, which creates a different finality model than optimistic rollups or L1 chains:

Stage 1: Sequencer confirmation (seconds). Your transaction is included in an L2 batch. eth_getTransactionReceipt returns status 1. This is the fastest confirmation you can get. For most in-app use cases (showing “confirmed” to users), this is sufficient.

Stage 2: ZK proof generation (minutes to hours). The sequencer batch is proven by the zkEVM prover. This runs off-chain and does not produce an on-chain event you can query via standard RPC.

Stage 3: L1 verification (Ethereum). The ZK proof batch is submitted to and verified by Ethereum. Once this happens, the X Layer state is final and irreversible. For withdrawals to Ethereum or for cross-chain operations that require L1 finality, wait for this stage.

For most DeFi operations on X Layer itself, Stage 1 confirmation is sufficient. For bridging funds from X Layer to Ethereum, you need Stage 3.

// Check receipt status: Stage 1 confirmation
const receipt = await provider.getTransactionReceipt(txHash);
if (receipt && receipt.status === 1) {
  console.log("Sequencer confirmed, safe for in-app display");
}

// For bridge operations, you need to monitor the bridge contract on Ethereum L1
// X Layer bridge: check the L1 bridge contract for proof verification events

OKX Ecosystem Integration

X Layer is native to the OKX ecosystem. Key integration touchpoints:

OKX DEX: OKX’s DEX aggregator routes trades through X Layer. Applications that interact with OKX DEX contracts on X Layer should account for the exchange’s traffic patterns: high volume during market events, token launches, promotional periods.

OKX Web3 Wallet: OKX’s Web3 wallet natively supports X Layer. Users with OKX wallets can connect to X Layer dApps without manual network configuration. For dApps targeting OKX users, X Layer is the primary EVM environment.

OKB token mechanics: OKB is a deflationary token with a buyback and burn mechanism. Gas fees on X Layer are paid in OKB. Unlike ETH on Ethereum L2s, OKB has additional utility across the OKX exchange ecosystem that affects its availability and pricing.


Production Issues on X Layer

OKX exchange traffic spikes. X Layer shares infrastructure and user base with OKX exchange. During significant market events (high volatility periods, major token listings), X Layer sees elevated transaction volume. The official OKX public RPC at https://rpc.xlayer.tech can slow under these conditions. Use a dedicated provider for consistent performance during peak periods.

OKB availability for gas. Users coming from other EVM chains may not have OKB for gas. X Layer has a gas sponsorship mechanism for dApp developers that lets your contract pay gas on behalf of users. This is especially useful for onboarding users who do not hold OKB.

Block time variance. X Layer targets approximately 3-second block times, but sequencer batch processing can vary. Do not hard-code timing assumptions. Use block number as your confirmation reference, not elapsed time.

Log query limits. Public nodes limit eth_getLogs to 10,000 blocks per query. Paginate large historical queries using consecutive block ranges.

Bridge transaction monitoring. Withdrawing from X Layer to Ethereum L1 involves a bridge contract. The time between X Layer transaction confirmation and Ethereum receipt depends on ZK proof batch timing. Monitor the official X Layer bridge status for withdrawal confirmation rather than relying on a fixed time window.


Choosing an X Layer RPC Provider

ConsiderationWhat to Look For
Availability during OKX eventsDedicated nodes unaffected by exchange traffic spikes
Low latency for DeFiX Layer blocks at ~3 seconds need consistent endpoint response
WebSocket supportEvent-driven apps need stable subscriptions
Flat pricingOKX ecosystem activity creates bursty call patterns

For dedicated X Layer RPC infrastructure: BoltRPC X Layer endpoint.


X Layer RPC FAQ

What is the X Layer RPC endpoint? Official public HTTP: https://rpc.xlayer.tech. For production, BoltRPC provides a dedicated endpoint at https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY. Chain ID is 196.

What is X Layer? X Layer is OKX’s Ethereum layer-2 blockchain built using Polygon CDK’s zkEVM technology. It settles to Ethereum via ZK proof verification and uses OKB as its native gas token. It is designed for OKX ecosystem integrations including OKX DEX and OKX Web3 wallet.

What chain ID is X Layer? X Layer Mainnet chain ID is 196 (0xc4 in hex). Always verify chain ID when connecting wallets or applications.

How does ZK proof finality work on X Layer? X Layer transactions have three stages: sequencer confirmation (seconds, sufficient for in-app use), ZK proof generation (minutes to hours), Ethereum L1 verification (final state). For most dApp operations Stage 1 is sufficient. For bridging to Ethereum, wait for Stage 3.

What is the difference between X Layer and other zkEVM chains? X Layer is built on Polygon CDK’s zkEVM implementation. It is EVM-compatible and supports standard Ethereum JSON-RPC. The primary differences are: OKB as native token (vs ETH on other L2s), OKX ecosystem integrations, exchange-correlated traffic patterns that do not occur on non-exchange-native L2s.

Do standard Ethereum libraries work with X Layer? Yes. ethers.js, Web3.py, viem, all standard Ethereum development tools work with X Layer. Connect to the X Layer RPC endpoint and set chain ID to 196. No X Layer-specific library changes are needed.


<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What is the X Layer RPC endpoint?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Official public HTTP: https://rpc.xlayer.tech. For production, BoltRPC provides a dedicated endpoint at https://eu.endpoints.matrixed.link/rpc/xlayer?auth=YOUR_KEY. Chain ID is 196."
      }
    },
    {
      "@type": "Question",
      "name": "What is X Layer?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "X Layer is OKX's Ethereum layer-2 blockchain built on Polygon CDK's zkEVM technology. It settles to Ethereum via ZK proof verification and uses OKB as its native gas token."
      }
    },
    {
      "@type": "Question",
      "name": "What chain ID is X Layer?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "X Layer Mainnet chain ID is 196 (0xc4 in hex). Always verify chain ID when connecting wallets or applications."
      }
    },
    {
      "@type": "Question",
      "name": "How does ZK proof finality work on X Layer?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "X Layer transactions have three stages: sequencer confirmation (seconds), ZK proof generation (minutes to hours), Ethereum L1 verification (final). For most dApp operations Stage 1 is sufficient. For bridging to Ethereum, wait for Stage 3."
      }
    },
    {
      "@type": "Question",
      "name": "Do standard Ethereum libraries work with X Layer?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes. ethers.js, Web3.py, viem, all standard Ethereum tools work with X Layer. Connect to the X Layer RPC endpoint and set chain ID to 196."
      }
    }
  ]
}
</script>

Frequently asked questions

Ready to build with high-performance RPC?

Start your free trial today. No credit card required. Access 20+ networks instantly.

Disclaimer: The content in this article is for informational purposes only and does not constitute financial, legal, or technical advice. Code examples and configurations are provided as-is. Always verify information with official documentation and test thoroughly in your own environment before deploying to production.

Continue reading