JSON-RPC
The GX EVM exposes a standard Ethereum JSON-RPC 2.0 interface on port 3001. This page documents the supported methods and GX-specific behavior.
Endpoint
| Environment | URL |
|---|---|
| Mainnet | https://rpc.gx.exchange |
| Testnet | https://rpc.gx-exchange-testnet.xyz |
| Local | http://localhost:3001 |
Request Format
Standard JSON-RPC 2.0:
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}Supported Methods
Chain Information
| Method | Description |
|---|---|
eth_chainId | Returns 0xA455 (42069 decimal) |
eth_blockNumber | Current block height |
net_version | Network ID ("42069") |
const provider = new ethers.JsonRpcProvider("https://rpc.gx.exchange");
const chainId = await provider.getNetwork();
console.log("Chain ID:", chainId.chainId); // 42069n
const blockNumber = await provider.getBlockNumber();
console.log("Block:", blockNumber);Account State
| Method | Description |
|---|---|
eth_getBalance | Native GX balance (wei) |
eth_getTransactionCount | Account nonce |
eth_getCode | Contract bytecode at address |
eth_getStorageAt | Raw storage slot value |
const balance = await provider.getBalance("0xYourAddress...");
console.log("GX balance:", ethers.formatEther(balance));
const nonce = await provider.getTransactionCount("0xYourAddress...");
console.log("Nonce:", nonce);Transaction Submission
| Method | Description |
|---|---|
eth_sendRawTransaction | Submit a signed transaction |
eth_estimateGas | Estimate gas for a transaction |
eth_call | Execute a read-only call (no state change) |
// Estimate gas
const gasEstimate = await provider.estimateGas({
to: "0xContractAddress...",
data: "0x...",
});
// Submit transaction
const tx = await wallet.sendTransaction({
to: "0xContractAddress...",
data: "0x...",
gasLimit: gasEstimate,
});
const receipt = await tx.wait();Block Data
| Method | Description |
|---|---|
eth_getBlockByNumber | Block by number (with or without full transactions) |
eth_getBlockByHash | Block by hash |
// Get latest block
const block = await provider.getBlock("latest");
// Get specific block with full transactions
const fullBlock = await provider.getBlock(1000, true);Transaction Data
| Method | Description |
|---|---|
eth_getTransactionByHash | Transaction details by hash |
eth_getTransactionReceipt | Transaction receipt (status, logs, gas used) |
const receipt = await provider.getTransactionReceipt("0xTxHash...");
console.log("Status:", receipt.status); // 1 = success
console.log("Gas used:", receipt.gasUsed);Event Logs
| Method | Description |
|---|---|
eth_getLogs | Query event logs by filter |
const logs = await provider.getLogs({
fromBlock: 1000,
toBlock: "latest",
address: "0xContractAddress...",
topics: [ethers.id("Transfer(address,address,uint256)")],
});Gas Price
| Method | Description |
|---|---|
eth_gasPrice | Current gas price suggestion |
eth_feeHistory | Historical fee data for EIP-1559 estimation |
const feeData = await provider.getFeeData();
console.log("Gas price:", feeData.gasPrice);
console.log("Max fee:", feeData.maxFeePerGas);
console.log("Max priority fee:", feeData.maxPriorityFeePerGas);Unsupported Methods
The following methods are not available on GX EVM:
| Method | Reason |
|---|---|
eth_mining | GX Chain uses PoS consensus, not PoW |
eth_hashrate | Not applicable to PoS |
eth_getWork | Not applicable to PoS |
eth_submitWork | Not applicable to PoS |
debug_* | Debug namespace not exposed on public endpoints |
trace_* | Trace namespace not exposed on public endpoints |
Batch Requests
The RPC endpoint supports JSON-RPC batch requests:
[
{ "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 },
{ "jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 2 },
{ "jsonrpc": "2.0", "method": "eth_gasPrice", "params": [], "id": 3 }
]The response is an array of results in the same order.
Rate Limits
| Tier | Limit |
|---|---|
| Public (per IP) | 100 requests/second |
eth_getLogs (per IP) | 20 requests/second |
| Batch request | Counts as N requests (one per item in the batch) |
WebSocket Subscriptions
The RPC endpoint also supports eth_subscribe over WebSocket for real-time event streaming:
const wsProvider = new ethers.WebSocketProvider("wss://rpc.gx.exchange/ws");
// Subscribe to new blocks
wsProvider.on("block", (blockNumber) => {
console.log("New block:", blockNumber);
});
// Subscribe to contract events
const filter = {
address: "0xContractAddress...",
topics: [ethers.id("Transfer(address,address,uint256)")],
};
wsProvider.on(filter, (log) => {
console.log("Transfer event:", log);
});Error Codes
| Code | Message | Description |
|---|---|---|
-32700 | Parse error | Invalid JSON |
-32600 | Invalid request | Missing required fields |
-32601 | Method not found | Unsupported RPC method |
-32602 | Invalid params | Wrong parameter types or count |
-32603 | Internal error | Server-side error |
-32000 | Execution reverted | Contract call reverted (includes revert reason) |
-32001 | Resource not found | Block or transaction not found |