Skip to main content
X Layer is OKX’s Ethereum layer 2, built on the OP Stack with OKB as the gas token. It is EVM-equivalent, so the standard Ethereum libraries and frameworks work against an X Layer node without modification. Chainstack serves X Layer Mainnet and X Layer Testnet on Global Nodes with archive data and both the debug_* and trace_* namespaces. See Debug and trace APIs.

Chain configuration

MetaMask

Add X Layer as a custom network. On Chainstack, get your X Layer endpoint, then in MetaMask select Add a custom network and fill in:
  • Network name — X Layer Mainnet
  • Default RPC URL — your Chainstack X Layer Mainnet endpoint
  • Chain ID — 196
  • Currency symbol — OKB
  • Block explorer URL — https://web3.okx.com/explorer/x-layer
For X Layer Testnet, use your Chainstack X Layer Testnet endpoint, chain ID 1952, and the block explorer URL https://web3.okx.com/explorer/x-layer-testnet.

ethers.js

Install ethers.js:
The address in the example is the wrapped OKB (WOKB) contract on X Layer Mainnet, which holds the OKB deposited into it. To receive new blocks as X Layer produces them, connect to the WSS endpoint and subscribe:

viem

viem ships xLayer (chain 196) and xLayerTestnet (chain 1952) chain definitions in viem/chains. Their default RPC URLs are OKX’s public endpoints, so pass your Chainstack endpoint to http(). Both definitions include the Multicall3 address, so client.multicall batches contract reads into a single eth_call.
For X Layer Testnet, import xLayerTestnet instead and pass your Chainstack X Layer Testnet endpoint.

web3.py

Install web3.py:
from_wei(balance, "ether") converts from the smallest unit with 18 decimals, which is the same conversion for OKB as for ETH.

Foundry

Install Foundry and pass your Chainstack endpoint with --rpc-url. Read chain data with cast:
Deploy a contract with forge create. Without --broadcast, forge create only simulates the deployment.
Verify the deployed contract on Sourcify, which supports both X Layer networks and does not need an API key. For X Layer Testnet, pass --chain 1952.
X Layer’s own explorers take verifications through OKLink, which needs an OKLink API key. See X Layer’s contract verification guide.

Hardhat

In a Hardhat 3 project that uses @nomicfoundation/hardhat-toolbox-viem, add the X Layer networks to hardhat.config.ts:
configVariable reads the endpoints and the key from environment variables or the Hardhat keystore, which keeps them out of the config file. Deploy with an Ignition module, for example ignition/modules/Counter.ts:
Then verify on Sourcify with the verify sourcify task. Hardhat has no built-in Etherscan or Blockscout explorer for X Layer, so the plain hardhat verify task reports the chain as not supported for those two providers.

X Layer behaviors that affect tooling

Transactions pay no L1 data fee

X Layer sets the L1 fee scalars in the GasPriceOracle predeploy at 0x420000000000000000000000000000000000000F to zero, so the OP Stack L1 data fee is zero. Transaction receipts still carry the l1Fee, l1GasUsed, l1GasPrice, and l1BlobBaseFee fields, with l1Fee at 0x0, and the total cost of a transaction is gasUsed × effectiveGasPrice.

Pending transactions are never delivered

X Layer is an OP Stack chain, so pending transactions stay with the sequencer. eth_subscribe("newPendingTransactions") and eth_newPendingTransactionFilter return an ID but deliver nothing, and txpool_status always reads empty. The pending block tag returns the latest block, not the Flashblocks preconfirmation state that X Layer’s own Flashblocks RPC serves. See What gives you mempool access.

Block-count limits and the proof window

X Layer produces a block every second, so a 10,000-block eth_getLogs request covers under 3 hours of chain time. eth_getProof serves the latest 256 blocks, about 4 minutes of chain time. See EVM range limits and EVM eth_getProof history limits.
Last modified on October 17, 2026