Saltar al contenido principal

Ethereum API Quick Start Guide

BlockEden.xyz provides high-performance, reliable Ethereum infrastructure through our comprehensive JSON-RPC API. Connect to Ethereum mainnet, testnets, and layer 2 solutions with enterprise-grade reliability and developer-friendly tools.

Overview

Our Ethereum API supports:

  • Ethereum Mainnet and all major testnets (Sepolia, Holesky)
  • Layer 2 Solutions (Polygon, Arbitrum, Optimism)
  • Full JSON-RPC Specification with debug and trace methods
  • WebSocket Connections for real-time data
  • Archive Node Access for historical data
  • MEV Protection and transaction simulation

Quick Start

Step 1: Get Your API Key

  1. Visit BlockEden.xyz Dashboard
  2. Sign up for a free account if you haven't already
  3. Create a new API key for Ethereum
  4. Select your target network (Mainnet, Sepolia, etc.)

Step 2: Make Your First Request

Using cURL

curl -X POST https://ethereum-mainnet.blockeden.xyz/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}'

Using JavaScript (Fetch)

const response = await fetch('https://ethereum-mainnet.blockeden.xyz/<your-api-key>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_blockNumber',
params: [],
id: 1
})
});

const data = await response.json();
console.log('Current block number:', parseInt(data.result, 16));

Using Python

import requests
import json

url = "https://ethereum-mainnet.blockeden.xyz/<your-api-key>"
payload = {
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}

response = requests.post(url, json=payload)
result = response.json()
print(f"Current block number: {int(result['result'], 16)}")

Core RPC Methods

Account Information

// Get account balance
{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4", "latest"],
"id": 1
}

// Get transaction count (nonce)
{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4", "latest"],
"id": 1
}

Block Information

// Get latest block
{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", true],
"id": 1
}

// Get block by hash
{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x1234...abcd", true],
"id": 1
}

Transaction Operations

// Get transaction by hash
{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x1234...abcd"],
"id": 1
}

// Send raw transaction
{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["0x1234...abcd"],
"id": 1
}

Network Endpoints

Mainnet

  • HTTP: https://ethereum-mainnet.blockeden.xyz/<your-api-key>
  • WebSocket: wss://ethereum-mainnet.blockeden.xyz/<your-api-key>

Testnets

  • Sepolia: https://ethereum-sepolia.blockeden.xyz/<your-api-key>
  • Holesky: https://ethereum-holesky.blockeden.xyz/<your-api-key>

Layer 2 Networks

  • Polygon: https://polygon-mainnet.blockeden.xyz/<your-api-key>
  • Arbitrum: https://arbitrum-mainnet.blockeden.xyz/<your-api-key>
  • Optimism: https://optimism-mainnet.blockeden.xyz/<your-api-key>

Authentication & Security

API Key Authentication

All requests require your API key in the URL path. Keep your API key secure and never expose it in client-side code.

Rate Limits

  • Free tier: 100 requests per second
  • Pro tier: 1,000 requests per second
  • Enterprise: Custom limits

Best Practices

  1. Use HTTPS for all API calls
  2. Implement retry logic with exponential backoff
  3. Cache responses when appropriate
  4. Monitor your usage in the dashboard
  5. Use batch requests for multiple operations

Common Use Cases

Check Account Balance

async function getBalance(address) {
const response = await fetch('https://ethereum-mainnet.blockeden.xyz/<your-api-key>', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getBalance',
params: [address, 'latest'],
id: 1
})
});

const data = await response.json();
const balanceWei = BigInt(data.result);
const balanceEth = balanceWei / BigInt('1000000000000000000');
return balanceEth.toString();
}

Monitor New Blocks

// Using WebSocket for real-time updates
const ws = new WebSocket('wss://ethereum-mainnet.blockeden.xyz/<your-api-key>');

ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'eth_subscribe',
params: ['newHeads'],
id: 1
}));
});

ws.on('message', (data) => {
const result = JSON.parse(data);
if (result.params) {
console.log('New block:', result.params.result);
}
});

Smart Contract Interaction

async function callContract(contractAddress, data) {
const response = await fetch('https://ethereum-mainnet.blockeden.xyz/<your-api-key>', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_call',
params: [
{
to: contractAddress,
data: data
},
'latest'
],
id: 1
})
});

return await response.json();
}

Error Handling

Common Error Codes

// Handle RPC errors properly
async function safeRpcCall(method, params) {
try {
const response = await fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method,
params,
id: 1
})
});

const data = await response.json();

if (data.error) {
throw new Error(`RPC Error ${data.error.code}: ${data.error.message}`);
}

return data.result;
} catch (error) {
console.error('RPC call failed:', error);
throw error;
}
}

Retry Logic

async function withRetry(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, i)));
}
}
}

Next Steps

Resources

Need Help?