RPC endpoint
X Layer Testnet's public Erigon endpoint at testrpc.xlayer.tech/terigon
works fine from server-side code (curl, graph-node, your backend) but
doesn't return CORS headers, so browser dapps can't fetch it
directly. xtruth runs a same-origin proxy that adds the headers and
forwards to upstream.
Endpoints
| Environment | URL |
|---|---|
| Production | https://app.xtruth.xyz/api/rpc |
| Test (sandbox) | https://app-dev.xtruth.xyz/api/rpc |
Both proxy to the same upstream and return identical results today — pick the test URL while developing. See Environments.
Example request
POST https://app-dev.xtruth.xyz/api/rpc
Content-Type: application/json
Body is a normal JSON-RPC request:
{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}
Response:
{ "jsonrpc": "2.0", "id": 1, "result": "0x7a0" }
0x7a0 = 1952 = X Layer Testnet.
Why a proxy
Without it:
wagmi/viemreads from the browser fail withFailed to fetch— silently rebadged asapprove() reverted: Failed to fetchby viem, which is misleading.- The user's wallet (MetaMask, OKX Wallet, etc.) also uses its own
configured RPC for
eth_estimateGas/eth_sendRawTransaction. If the wallet is pointed at the public endpoint, writes fail too.
The proxy lives at the same origin as the dapp, so the browser bypasses CORS entirely.
Use it in viem / wagmi
import { defineChain, http } from "viem";
const xlayerTestnet = defineChain({
id: 1952,
name: "X Layer Testnet",
nativeCurrency: { name: "OKB", symbol: "OKB", decimals: 18 },
rpcUrls: {
default: { http: ["https://app.xtruth.xyz/api/rpc"] },
},
});
const client = createPublicClient({
chain: xlayerTestnet,
transport: http(),
});
Use it in your wallet
The dapp ships a one-click button that calls wallet_addEthereumChain
(EIP-3085) to add (or update) X Layer Testnet using the proxy URL. From
the oracle/new page, after a Failed
to fetch error, click Use xtruth RPC in wallet and confirm in the
wallet popup.
You can also configure manually:
- Network name: X Layer Testnet (xtruth proxy)
- RPC URL:
https://app.xtruth.xyz/api/rpc - Chain ID: 1952
- Currency symbol: OKB
- Block explorer: https://www.oklink.com/xlayer-test
Limits & quotas
Free tier today, no auth, no rate limit (yet). Cloudflare Workers handles
the load. If usage grows we'll add per-IP rate limits and method
allowlisting (eth_call, eth_chainId, eth_blockNumber,
eth_getLogs — block eth_sendRawTransaction so users go through their
own wallets).
Source
The proxy is a single edge function: see xtruth-app/src/app/api/rpc/route.ts. 40 lines including the upstream fallback and CORS headers.