Supported ChainX Layer
X Layer API
Access X Layer via the Spectrum unified API. X Layer is OKX’s Polygon CDK zkEVM L2.
Properties
| Property | Value |
|---|---|
| Slug | xlayer |
| Type | zkEVM L2 |
| Native Token | OKB |
| Chain ID | 196 |
Available Methods
| Method | Description |
|---|---|
| getBlockHeight | Latest X Layer block number |
| getBalance | OKB balance for a wallet |
| getTokenBalance | ERC-20 token balance |
| getTokenMetadata | ERC-20 token info |
| getTokenAllowance | Token spending allowance |
| getPortfolio | Full portfolio with USD values |
| getNftCollection | NFT holdings for a wallet |
| getBlockTransactions | Transactions in a block |
| estimateGas | Gas estimation for a transaction |
| traceTransaction | Internal call trace |
| getCode | Contract bytecode check |
| simulateCall | Simulate a contract call |
| rpcProxy | Raw JSON-RPC passthrough |
| getChainHealth | X Layer RPC health check |
Quick Start
Get the latest X Layer block height:
curl -X POST https://your-endpoint.simplystaking.xyz/v1 \ -H "Content-Type: application/json" \
{ "jsonrpc": "2.0", "method": "getBlockHeight", "params": { "chain": "xlayer" }, "id": 1 }
Get Balance
Retrieve the OKB balance for a wallet address on X Layer:
curl -X POST https://your-endpoint.simplystaking.xyz/v1 \ -H "Content-Type: application/json" \
{ "jsonrpc": "2.0", "method": "getBalance", "params": { "chain": "xlayer", "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" }, "id": 1 }
Get Gas
Compare current gas prices across chains:
curl -X POST https://your-endpoint.simplystaking.xyz/v1 \ -H "Content-Type: application/json" \
{ "jsonrpc": "2.0", "method": "compareGas", "params": {}, "id": 1 }
SDK
import { Spectrum } from '@spectrumnodes/sdk';
const spectrum = new Spectrum({ api: 'https://your-endpoint.simplystaking.xyz/YOUR_API_KEY/' });
// Get latest block height
const block = await spectrum.core.getBlockHeight('xlayer');
console.log(block.height);
// Get OKB balance on X Layer
const balance = await spectrum.tokens.getBalance('xlayer', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045');
console.log(balance.balance);DeFi
Standard EVM endpoints; DeFi protocol integrations are added as they roll out.