Blockchain developers building on X Layer need reliable and efficient access to network data and transaction execution capabilities. The X Layer network supports JSON-RPC endpoints that are fully compatible with Ethereum standards, as well as specialized zkEVM RPC methods designed for zero-knowledge rollup functionality. Whether you're deploying smart contracts, querying blockchain state, or monitoring transaction confirmations, understanding how to interact with these endpoints is essential.
This guide provides a comprehensive overview of X Layer's supported RPC methods, mainnet and testnet configurations, usage examples, and best practices for developers integrating with the network.
X Layer Mainnet and Testnet RPC Endpoints
X Layer operates on two primary networks: Mainnet for production applications and Testnet for development and testing. Each has its own chain ID and dedicated RPC URLs.
Mainnet (Chain ID: 196)
- Chain ID (decimal):
196 - Chain ID (hex):
0xC4 RPC Endpoints:
https://rpc.xlayer.techhttps://xlayerrpc.okx.com
👉 Discover how to connect your wallet securely to X Layer Mainnet using these RPCs.
Testnet (Chain ID: 195)
- Chain ID (decimal):
195 - Chain ID (hex):
0xC3 RPC Endpoints:
https://testrpc.xlayer.techhttps://xlayertestrpc.okx.com
Both networks enforce a rate limit of 100 requests per second per IP address, which helps maintain stability and prevent abuse. For high-frequency applications such as indexers or trading bots, consider using dedicated infrastructure providers for enhanced performance.
Prerequisite Knowledge
Before diving into RPC usage, it's recommended to familiarize yourself with Ethereum’s JSON-RPC API standards. Since X Layer maintains compatibility with Ethereum, many of the methods behave similarly.
Key resources:
Understanding core concepts like eth_call, eth_sendRawTransaction, and block validation will greatly assist in leveraging X Layer’s capabilities effectively.
How to Use HTTP JSON-RPC on X Layer
To interact with X Layer via HTTP, use the curl command-line tool or any HTTP client that supports POST requests. Here's an example of fetching the current block number:
curl -X POST https://rpc.xlayer.tech \
-H "Content-Type: application/json" \
--data '{
"jsonrpc":"2.0",
"method":"eth_blockNumber",
"params":[],
"id":1
}'This returns a response like:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1b4"
}You can replace the method and parameters to query balances, send transactions, or debug execution traces.
Supported JSON-RPC Methods on X Layer
X Layer supports two categories of RPC methods: Ethereum-compatible and ZKEVM-specific.
1. Ethereum-Compatible RPC Methods
These methods mirror standard Ethereum behavior, enabling seamless migration of dApps from Ethereum or EVM-based chains.
| Method | Function |
|---|---|
eth_blockNumber | Get current block height |
eth_getBalance | Retrieve account balance |
eth_sendRawTransaction | Broadcast signed transactions |
eth_estimateGas | Estimate gas required for a transaction |
eth_getTransactionReceipt | Check if a transaction was confirmed |
eth_call | Simulate contract calls without sending transactions |
debug_traceTransaction | Trace internal operations of a transaction |
Notable differences from standard Ethereum nodes:
eth_protocolVersionalways returns'0'- Uncle-related methods (
eth_getUncleByBlockHashAndIndex, etc.) return empty responses txpool_contentis not supported
For full details, refer to the official Ethereum JSON-RPC docs.
👉 Learn how to optimize gas usage when interacting with Ethereum-compatible endpoints.
2. ZKEVM-Specific RPC Methods
As a zkEVM-based layer-2 solution, X Layer introduces unique methods to monitor batch processing and verification status — critical for understanding finality and security.
Core ZKEVM Methods
zkevm_batchNumber: Returns the latest batch numberzkevm_verifiedBatchNumber: Gets the most recently verified batchzkevm_virtualBatchNumber: Retrieves the latest virtualized batchzkevm_isBlockConsolidated: Checks if a block’s batch has been verifiedzkevm_isBlockVirtualized: Determines if a block is included in a virtual batchzkevm_getBatchByNumber: Fetch detailed batch information
Example: Check Batch Finality
Use this call to determine whether a specific block has reached finality:
curl -X POST https://rpc.xlayer.tech \
-H "Content-Type: application/json" \
--data '{
"jsonrpc":"2.0",
"method":"zkevm_isBlockConsolidated",
"params":["0x1234"],
"id":1
}'A return value of true means the block is part of a verified batch — indicating strong cryptographic finality.
Infrastructure Providers for Scalable Access
Public RPC endpoints are suitable for light development but may throttle under heavy load. For production-grade applications requiring consistent uptime and higher throughput, consider partnering with infrastructure providers:
- ZAN: Offers global node distribution and low-latency access
- Ankr: Provides scalable Web3 APIs with advanced caching
These platforms allow developers to bypass public rate limits and ensure reliable connectivity.
👉 Explore how leading dApps scale their RPC access through optimized infrastructure solutions.
Frequently Asked Questions (FAQ)
Q: What is the rate limit for X Layer RPC endpoints?
A: Both mainnet and testnet impose a limit of 100 requests per second per IP address. Exceeding this may result in temporary throttling.
Q: How do I know when a transaction is finalized on X Layer?
A: Use zkevm_isBlockConsolidated to check if the block containing your transaction belongs to a verified batch. Only verified batches achieve full finality.
Q: Can I use MetaMask with X Layer?
A: Yes. You can manually add X Layer Mainnet or Testnet to MetaMask using the Chain ID and RPC URL. Ensure you're using correct network settings to avoid failed transactions.
Q: Why do some Ethereum methods return empty responses?
A: Certain methods like eth_getUncleCountByBlockNumber or eth_getCompilers are unsupported due to architectural differences in zkEVM design. These return empty values by design.
Q: What does “virtualized” mean in zkEVM context?
A: A block is “virtualized” when it's included in a batch submitted to L1 but not yet proven. It's one step before full verification and finality.
Q: How can I reduce latency when querying blockchain data?
A: Use dedicated node services like Ankr or ZAN instead of public RPCs, or run your own node for maximum control and speed.
Conclusion
X Layer delivers a robust foundation for developers through Ethereum-compatible JSON-RPC and powerful zkEVM-specific extensions. With clear documentation, predictable behavior, and scalable infrastructure support, building decentralized applications on this platform is both efficient and secure.
Whether you're verifying transaction finality, estimating gas costs, or debugging smart contract execution, mastering these RPC endpoints is key to unlocking the full potential of X Layer.
Core Keywords: RPC endpoints, X Layer, zkEVM, JSON-RPC, Ethereum-compatible, block verification, batch finality, developer tools