XDC Gateway Documentation

XDC Gateway provides enterprise-grade RPC infrastructure for XDC Network and 15+ other blockchain networks. Access reliable, fast, and scalable blockchain data through a unified API.

Quick Start

Get started in 3 simple steps:

1. Create an Account

Sign up at cloud.xdcrpc.com/signup to create your free account. No credit card required.

2. Generate an API Key

Navigate to the API Keys section in your dashboard and create a new key. Each key can be configured with specific rate limits and network access.

3. Make Your First Request

Use your API key to make RPC requests:

curl -X POST https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x5e903a6"
}

Authentication

All RPC requests require an API key. Include your key in the URL path:

https://ecloud.xdcrpc.com/{network}/{apiKey}

API keys are tied to your account and can be managed from the dashboard. You can create multiple keys for different applications or environments.

Security Best Practices

  • Never expose API keys in client-side code or public repositories
  • Use environment variables for key storage
  • Rotate keys periodically (recommended every 90 days)
  • Set appropriate rate limits per key
  • Use separate keys for development and production environments

API Reference Overview

XDC Gateway provides a REST API for managing your account, API keys, and accessing additional services. Base URL for all REST API requests:

https://cloud.xdcrpc.com/api/v1

Authentication

All API endpoints require authentication via Bearer token in the Authorization header:

Authorization: Bearer {your_access_token}

Auth Endpoints

POST/auth/register

Create a new account.

Request Body

{
  "email": "user@example.com",
  "password": "securePassword123",
  "name": "John Doe"
}

Response

{
  "success": true,
  "data": {
    "user": {
      "id": "user_uuid",
      "email": "user@example.com",
      "name": "John Doe",
      "tier": "free"
    },
    "tokens": {
      "accessToken": "eyJhbGciOiJIUzI1NiIs...",
      "refreshToken": "eyJhbGciOiJIUzI1NiIs..."
    }
  }
}
POST/auth/login

Authenticate and receive access tokens.

Request Body

{
  "email": "user@example.com",
  "password": "securePassword123"
}

Response

{
  "success": true,
  "data": {
    "user": {
      "id": "user_uuid",
      "email": "user@example.com",
      "name": "John Doe",
      "tier": "pro"
    },
    "tokens": {
      "accessToken": "eyJhbGciOiJIUzI1NiIs...",
      "refreshToken": "eyJhbGciOiJIUzI1NiIs..."
    }
  }
}
POST/auth/refresh

Refresh access token using refresh token.

Request Body

{
  "refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}

Response

{
  "success": true,
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIs...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIs..."
  }
}

Network Endpoints

GET/networks

List all available blockchain networks.

Response

{
  "success": true,
  "data": [
    {
      "id": "network_uuid",
      "name": "XDC Mainnet",
      "slug": "xdc-mainnet",
      "chainId": 50,
      "type": "mainnet",
      "rpcUrl": "https://ecloud.xdcrpc.com/xdc-mainnet",
      "currency": {
        "name": "XDC",
        "symbol": "XDC",
        "decimals": 18
      }
    },
    {
      "id": "network_uuid_2",
      "name": "XDC Testnet",
      "slug": "xdc-testnet",
      "chainId": 51,
      "type": "testnet",
      "rpcUrl": "https://ecloud.xdcrpc.com/xdc-testnet",
      "currency": {
        "name": "XDC",
        "symbol": "XDC",
        "decimals": 18
      }
    }
  ]
}
GET/networks/:slug

Get details for a specific network by slug.

Path Parameters

ParameterTypeDescription
slugstringNetwork slug (e.g., xdc-mainnet)

Response

{
  "success": true,
  "data": {
    "id": "network_uuid",
    "name": "XDC Mainnet",
    "slug": "xdc-mainnet",
    "chainId": 50,
    "type": "mainnet",
    "rpcUrl": "https://ecloud.xdcrpc.com/xdc-mainnet",
    "explorerUrl": "https://explorer.xinfin.network",
    "currency": {
      "name": "XDC",
      "symbol": "XDC",
      "decimals": 18
    },
    "supportedMethods": [
      "eth_blockNumber",
      "eth_getBalance",
      "eth_sendRawTransaction",
      "..."
    ]
  }
}

API Key Endpoints

GET/api-keys

List all API keys for your account.

Response

{
  "success": true,
  "data": [
    {
      "id": "key_uuid",
      "name": "Production Key",
      "key": "xg_live_abc123...",
      "prefix": "xg_live",
      "networks": ["xdc-mainnet", "ethereum"],
      "rateLimit": 1000,
      "usage": {
        "daily": 5420,
        "monthly": 125000
      },
      "createdAt": "2024-01-15T10:30:00Z",
      "lastUsedAt": "2024-02-10T08:45:00Z"
    }
  ]
}
POST/api-keys

Create a new API key.

Request Body

{
  "name": "My App Key",
  "networks": ["xdc-mainnet", "xdc-testnet"],
  "rateLimit": 100
}

Response

{
  "success": true,
  "data": {
    "id": "key_uuid",
    "name": "My App Key",
    "key": "xg_live_xyz789...",
    "prefix": "xg_live",
    "networks": ["xdc-mainnet", "xdc-testnet"],
    "rateLimit": 100,
    "createdAt": "2024-02-10T20:00:00Z"
  }
}
DELETE/api-keys/:id

Delete an API key. This action cannot be undone.

Response

{
  "success": true,
  "message": "API key deleted successfully"
}

Usage Endpoints

GET/usage/stats

Get usage statistics for your account.

Query Parameters

ParameterTypeRequiredDescription
startDatestringNoStart date (YYYY-MM-DD)
endDatestringNoEnd date (YYYY-MM-DD)

Response

{
  "success": true,
  "data": {
    "period": {
      "start": "2024-02-01",
      "end": "2024-02-10"
    },
    "totalRequests": 125000,
    "requestsByNetwork": {
      "xdc-mainnet": 85000,
      "ethereum": 25000,
      "polygon": 15000
    },
    "requestsByMethod": {
      "eth_blockNumber": 45000,
      "eth_getBalance": 35000,
      "eth_call": 25000
    },
    "dailyBreakdown": [
      {
        "date": "2024-02-10",
        "requests": 15420
      }
    ]
  }
}

Faucet Endpoints

Request test tokens for development on testnets.

POST/faucet/request

Request test tokens from the faucet.

Request Body

{
  "network": "xdc-testnet",
  "address": "0x...",
  "amount": "1000"
}

Response

{
  "success": true,
  "data": {
    "txHash": "0x...",
    "amount": "1000",
    "network": "xdc-testnet",
    "recipient": "0x..."
  }
}
GET/faucet/balance

Get current faucet balance for all testnet networks.

Response

{
  "success": true,
  "data": {
    "xdc-testnet": {
      "balance": "10000000",
      "symbol": "XDC",
      "faucetAddress": "0x..."
    },
    "ethereum-sepolia": {
      "balance": "5000000",
      "symbol": "ETH",
      "faucetAddress": "0x..."
    }
  }
}

Whale Alerts

Get notified about large transactions on XDC Network.

GET/whale-alerts

Fetch recent whale alerts (large transactions).

Query Parameters

ParameterTypeDefaultDescription
limitinteger20Number of results (max 100)
minValuestring100000Minimum transaction value in XDC

Response

{
  "success": true,
  "data": [
    {
      "id": "alert_uuid",
      "txHash": "0x...",
      "from": "0x...",
      "to": "0x...",
      "value": "500000",
      "valueUsd": 25000,
      "timestamp": "2024-02-10T19:30:00Z",
      "blockNumber": 68923000
    }
  ]
}

RPC Endpoints

Base URL for all RPC requests:

https://ecloud.xdcrpc.com/{network}/{apiKey}

Example Endpoints

# XDC Mainnet
https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY

# XDC Testnet
https://ecloud.xdcrpc.com/xdc-testnet/YOUR_API_KEY

# Ethereum
https://ecloud.xdcrpc.com/ethereum/YOUR_API_KEY

# Polygon
https://ecloud.xdcrpc.com/polygon/YOUR_API_KEY

Supported Methods

XDC Gateway supports all standard Ethereum JSON-RPC methods. Common methods include:

MethodDescription
eth_blockNumberReturns the current block number
eth_getBalanceReturns the balance of an address
eth_getBlockByNumberReturns block data by number
eth_getBlockByHashReturns block data by hash
eth_getTransactionByHashReturns transaction data
eth_getTransactionReceiptReturns transaction receipt
eth_sendRawTransactionSubmits a signed transaction
eth_callExecutes a call without creating a transaction
eth_estimateGasEstimates gas for a transaction
eth_gasPriceReturns current gas price
eth_chainIdReturns the chain ID
eth_getLogsReturns logs matching filter criteria
eth_getCodeReturns code at a given address
eth_getStorageAtReturns storage value at a position
eth_getTransactionCountReturns nonce for an address
eth_syncingReturns sync status
eth_miningReturns mining status
net_versionReturns network version
web3_clientVersionReturns client version

XDC-Specific Methods

XDC Network extends standard Ethereum JSON-RPC with additional methods:

MethodDescription
xdc_getBlockByNumberXDC-specific block retrieval
xdc_getCandidatesGet masternode candidates
xdc_getMasternodesGet active masternodes
xdc_getValidatorRewardGet validator rewards
xdc_getVoterRewardGet voter rewards

Example Request

curl -X POST https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "xdc_getCandidates",
    "params": ["latest"],
    "id": 1
  }'

Supported Networks

XDC Gateway supports the following networks:

NetworkSlugChain ID
XDC Mainnetxdc-mainnet50
XDC Testnetxdc-testnet51
Ethereumethereum1
Ethereum Sepoliaethereum-sepolia11155111
Polygonpolygon137
Polygon Amoypolygon-amoy80002
BNB Chainbsc56
BNB Testnetbsc-testnet97
Arbitrum Onearbitrum42161
Arbitrum Sepoliaarbitrum-sepolia421614
Optimismoptimism10
Optimism Sepoliaoptimism-sepolia11155420
Basebase8453
Base Sepoliabase-sepolia84532
Avalanche C-Chainavalanche43114
Avalanche Fujiavalanche-fuji43113

Rate Limits

Rate limits vary by plan:

PlanRequests/MinDaily LimitMonthly Limit
Free10010,000100,000
Pro1,000100,0001,000,000
Max5,000500,0005,000,000
EnterpriseUnlimitedUnlimitedCustom

Rate Limit Headers

Responses include rate limit information in headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1707609600

Pricing

Free

$0/month

  • 100 req/min
  • 100,000 requests/month
  • 3 API keys
  • 5 networks
  • Community support
Popular

Pro

$49/month

  • 1,000 req/min
  • 1,000,000 requests/month
  • 10 API keys
  • All 16+ networks
  • Priority email support
  • Advanced analytics

Max

$199/month

  • 5,000 req/min
  • 5,000,000 requests/month
  • 25 API keys
  • All 16+ networks
  • Priority support
  • Webhooks
  • Whale alerts

Enterprise

Custom

  • Unlimited requests/min
  • Unlimited requests
  • Unlimited API keys
  • All 16+ networks
  • Dedicated support
  • SLA guarantee
  • Custom features

Error Codes

XDC Gateway uses standard JSON-RPC error codes with additional custom codes:

CodeMessage
-32001Invalid or inactive API key
-32002API key revoked or expired
-32003API key not authorized for network
-32004Unknown network
-32005Rate limit exceeded
-32006Daily request limit exceeded
-32000Upstream RPC error

HTTP Status Codes

StatusDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
429Too Many Requests - Rate limit exceeded
500Internal Server Error

JavaScript / TypeScript SDK

Use XDC Gateway with popular Web3 libraries:

ethers.js v6

import { ethers } from 'ethers';

// Create provider
const provider = new ethers.JsonRpcProvider(
  'https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY'
);

// Get current block number
const blockNumber = await provider.getBlockNumber();
console.log('Current block:', blockNumber);

// Get balance
const balance = await provider.getBalance('0x...');
console.log('Balance:', ethers.formatEther(balance), 'XDC');

// Get block details
const block = await provider.getBlock(blockNumber);
console.log('Block timestamp:', block?.timestamp);

// Send transaction (requires signer)
const signer = new ethers.Wallet(privateKey, provider);
const tx = await signer.sendTransaction({
  to: '0x...',
  value: ethers.parseEther('1.0')
});
await tx.wait();
console.log('Transaction confirmed:', tx.hash);

web3.js

import Web3 from 'web3';

// Create Web3 instance
const web3 = new Web3(
  'https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY'
);

// Get current block number
const blockNumber = await web3.eth.getBlockNumber();
console.log('Current block:', blockNumber);

// Get balance
const balance = await web3.eth.getBalance('0x...');
console.log('Balance:', web3.utils.fromWei(balance, 'ether'), 'XDC');

// Get block details
const block = await web3.eth.getBlock(blockNumber);
console.log('Block timestamp:', block.timestamp);

// Send transaction (requires account)
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
web3.eth.accounts.wallet.add(account);

const tx = {
  from: account.address,
  to: '0x...',
  value: web3.utils.toWei('1', 'ether'),
  gas: 21000
};

const receipt = await web3.eth.sendTransaction(tx);
console.log('Transaction confirmed:', receipt.transactionHash);

viem

import { createPublicClient, createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { xdc, xdcTestnet } from 'viem/chains';

// Create public client (read-only)
const publicClient = createPublicClient({
  chain: xdc,
  transport: http('https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY')
});

// Get block number
const blockNumber = await publicClient.getBlockNumber();
console.log('Current block:', blockNumber);

// Get balance
const balance = await publicClient.getBalance({ 
  address: '0x...' 
});
console.log('Balance:', balance);

// Get block
const block = await publicClient.getBlock({ blockNumber });
console.log('Block timestamp:', block.timestamp);

// Create wallet client (for transactions)
const account = privateKeyToAccount(privateKey);
const walletClient = createWalletClient({
  account,
  chain: xdc,
  transport: http('https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY')
});

// Send transaction
const hash = await walletClient.sendTransaction({
  to: '0x...',
  value: parseEther('1')
});

const receipt = await publicClient.waitForTransactionReceipt({ hash });
console.log('Transaction confirmed:', receipt.transactionHash);

Python SDK

web3.py

from web3 import Web3

# Create Web3 instance
w3 = Web3(Web3.HTTPProvider(
    'https://ecloud.xdcrpc.com/xdc-mainnet/YOUR_API_KEY'
))

# Check connection
print(f"Connected: {w3.is_connected()}")

# Get current block number
block_number = w3.eth.block_number
print(f'Current block: {block_number}')

# Get balance
address = '0x...'
balance = w3.eth.get_balance(address)
print(f'Balance: {w3.from_wei(balance, "ether")} XDC')

# Get block details
block = w3.eth.get_block(block_number)
print(f'Block timestamp: {block.timestamp}')

# Send transaction (requires private key)
from eth_account import Account

account = Account.from_key(private_key)

tx = {
    'to': '0x...',
    'value': w3.to_wei(1, 'ether'),
    'gas': 21000,
    'gasPrice': w3.eth.gas_price,
    'nonce': w3.eth.get_transaction_count(account.address),
    'chainId': 50  # XDC Mainnet
}

# Sign and send
signed_tx = account.sign_transaction(tx)
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print(f'Transaction confirmed: {tx_hash.hex()}')

Postman Collection

Download our Postman collection to quickly test all API endpoints:

Download Postman Collection