Base JSON-RPC API Reference
Complete reference for Base's JSON-RPC API methods available through BlockEden.xyz. Base is fully EVM-compatible, supporting all standard Ethereum JSON-RPC methods with Layer 2 optimizations.
Endpoint
POST https://api.blockeden.xyz/base/<your-api-key>
Request Format
All requests use the JSON-RPC 2.0 protocol:
{
"jsonrpc": "2.0",
"method": "method_name",
"params": [...],
"id": 1
}
Response Format
{
"jsonrpc": "2.0",
"result": "...",
"id": 1
}
Account Methods
eth_getBalance
Returns the balance of an account at a given block.
Parameters:
address
- Address to check for balanceblock
- Block number or tag ("latest"
,"earliest"
,"pending"
)
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4", "latest"],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x1b1ae4d6e2ef500000",
"id": 1
}
eth_getTransactionCount
Returns the number of transactions sent from an address (nonce).
Parameters:
address
- Address to get transaction count forblock
- Block number or tag
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4", "latest"],
"id": 1
}'
eth_getCode
Returns the contract code at a given address.
Parameters:
address
- Contract addressblock
- Block number or tag
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0xa0b86a33e6d4c3d0c4f74d08ba3c8b7c2d1e8b9f", "latest"],
"id": 1
}'
Block Methods
eth_blockNumber
Returns the current block number.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x1b4",
"id": 1
}
eth_getBlockByNumber
Returns block information by block number.
Parameters:
block
- Block number (hex) or tagfull_transactions
- Iftrue
, returns full transaction objects
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", false],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": {
"number": "0x1b4",
"hash": "0x...",
"parentHash": "0x...",
"timestamp": "0x...",
"gasLimit": "0x1c9c380",
"gasUsed": "0x...",
"transactions": ["0x..."]
},
"id": 1
}
eth_getBlockByHash
Returns block information by block hash.
Parameters:
hash
- Block hashfull_transactions
- Iftrue
, returns full transaction objects
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x...", false],
"id": 1
}'
Transaction Methods
eth_sendRawTransaction
Submits a signed transaction to the network.
Parameters:
data
- Signed transaction data (hex)
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["0xf86c0a85174876e800825208944592d8f8d7b001e72cb26a73e4fa1806a51ac79d880de0b6b3a764000080820a95a0..."],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x...",
"id": 1
}
eth_getTransactionReceipt
Returns the receipt of a transaction by hash.
Parameters:
hash
- Transaction hash
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": ["0x..."],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": {
"blockHash": "0x...",
"blockNumber": "0x1b4",
"contractAddress": null,
"cumulativeGasUsed": "0x...",
"gasUsed": "0x5208",
"logs": [],
"status": "0x1",
"transactionHash": "0x...",
"transactionIndex": "0x0"
},
"id": 1
}
eth_getTransactionByHash
Returns transaction information by hash.
Parameters:
hash
- Transaction hash
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x..."],
"id": 1
}'
Contract Methods
eth_call
Executes a message call immediately without creating a transaction.
Parameters:
transaction
- Transaction call objectblock
- Block number or tag
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0xa0b86a33e6d4c3d0c4f74d08ba3c8b7c2d1e8b9f",
"data": "0x70a08231000000000000000000000000742d5cc6bf2442e8c7c74c7b4be6ab9d6f10f5b4"
}, "latest"],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"id": 1
}
eth_estimateGas
Estimates the gas needed to execute a transaction.
Parameters:
transaction
- Transaction call object
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [{
"from": "0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4",
"to": "0xa0b86a33e6d4c3d0c4f74d08ba3c8b7c2d1e8b9f",
"value": "0x9184e72a"
}],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x5208",
"id": 1
}
eth_getLogs
Returns logs matching the given filter.
Parameters:
filter
- Filter object
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"fromBlock": "0x1",
"toBlock": "latest",
"address": "0xa0b86a33e6d4c3d0c4f74d08ba3c8b7c2d1e8b9f"
}],
"id": 1
}'
Gas Methods
eth_gasPrice
Returns the current gas price in wei.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x9184e72a000",
"id": 1
}
eth_feeHistory
Returns base fee and priority fee history.
Parameters:
block_count
- Number of blocks to returnnewest_block
- Newest block number or tagreward_percentiles
- Array of percentile values
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_feeHistory",
"params": ["0x4", "latest", [25, 75]],
"id": 1
}'
eth_maxPriorityFeePerGas
Returns the current max priority fee per gas.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_maxPriorityFeePerGas",
"params": [],
"id": 1
}'
Network Methods
eth_chainId
Returns the chain ID of the network.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}'
Response:
{
"jsonrpc": "2.0",
"result": "0x2105",
"id": 1
}
net_version
Returns the network ID.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}'
net_listening
Returns true
if the client is actively listening for network connections.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "net_listening",
"params": [],
"id": 1
}'
Filter Methods
eth_newFilter
Creates a new filter object for event logs.
Parameters:
filter
- Filter options
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [{
"fromBlock": "0x1",
"toBlock": "latest",
"address": "0xa0b86a33e6d4c3d0c4f74d08ba3c8b7c2d1e8b9f"
}],
"id": 1
}'
eth_newBlockFilter
Creates a filter in the node to notify when a new block arrives.
Parameters: None
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}'
eth_getFilterChanges
Returns an array of logs that occurred since the last poll.
Parameters:
filter_id
- Filter ID
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": ["0x1"],
"id": 1
}'
Layer 2 Specific Methods
eth_getBlockTransactionCountByNumber
Returns the number of transactions in a block by block number.
Parameters:
block
- Block number (hex) or tag
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": ["latest"],
"id": 1
}'
eth_getUncleCountByBlockNumber
Returns the number of uncles in a block. Always returns 0x0
on Base.
Parameters:
block
- Block number (hex) or tag
Example:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleCountByBlockNumber",
"params": ["latest"],
"id": 1
}'
Code Examples
JavaScript/TypeScript
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://api.blockeden.xyz/base/<your-api-key>');
// Get account balance
async function getBalance(address) {
const balance = await provider.getBalance(address);
return ethers.formatEther(balance);
}
// Get transaction receipt
async function getTransactionReceipt(txHash) {
const receipt = await provider.getTransactionReceipt(txHash);
return receipt;
}
// Call smart contract method
async function callContract(contractAddress, abi, methodName, params = []) {
const contract = new ethers.Contract(contractAddress, abi, provider);
const result = await contract[methodName](...params);
return result;
}
// Send transaction
async function sendTransaction(wallet, to, value) {
const tx = await wallet.sendTransaction({
to: to,
value: ethers.parseEther(value),
gasLimit: 21000
});
const receipt = await tx.wait();
return receipt;
}
Python
import requests
import json
class BaseRPC:
def __init__(self, api_key):
self.url = f"https://api.blockeden.xyz/base/{api_key}"
self.headers = {'Content-Type': 'application/json'}
def call(self, method, params=None):
payload = {
"jsonrpc": "2.0",
"method": method,
"params": params or [],
"id": 1
}
response = requests.post(self.url, json=payload, headers=self.headers)
return response.json()
def get_balance(self, address, block="latest"):
result = self.call("eth_getBalance", [address, block])
return int(result["result"], 16)
def get_block_number(self):
result = self.call("eth_blockNumber")
return int(result["result"], 16)
def get_transaction_receipt(self, tx_hash):
result = self.call("eth_getTransactionReceipt", [tx_hash])
return result["result"]
# Usage
rpc = BaseRPC("your-api-key")
block_number = rpc.get_block_number()
print(f"Current block: {block_number}")
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params"`
ID int `json:"id"`
}
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
Result interface{} `json:"result"`
Error *RPCError `json:"error"`
ID int `json:"id"`
}
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
}
type BaseClient struct {
URL string
}
func NewBaseClient(apiKey string) *BaseClient {
return &BaseClient{
URL: fmt.Sprintf("https://api.blockeden.xyz/base/%s", apiKey),
}
}
func (c *BaseClient) Call(method string, params interface{}) (*RPCResponse, error) {
req := RPCRequest{
JSONRPC: "2.0",
Method: method,
Params: params,
ID: 1,
}
jsonData, err := json.Marshal(req)
if err != nil {
return nil, err
}
resp, err := http.Post(c.URL, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var rpcResp RPCResponse
err = json.Unmarshal(body, &rpcResp)
if err != nil {
return nil, err
}
return &rpcResp, nil
}
func (c *BaseClient) GetBlockNumber() (string, error) {
resp, err := c.Call("eth_blockNumber", []interface{}{})
if err != nil {
return "", err
}
if resp.Error != nil {
return "", fmt.Errorf("RPC error: %s", resp.Error.Message)
}
return resp.Result.(string), nil
}
func (c *BaseClient) GetBalance(address, block string) (string, error) {
resp, err := c.Call("eth_getBalance", []interface{}{address, block})
if err != nil {
return "", err
}
if resp.Error != nil {
return "", fmt.Errorf("RPC error: %s", resp.Error.Message)
}
return resp.Result.(string), nil
}
Error Handling
Common Errors
Invalid Parameters:
{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params"
},
"id": 1
}
Method Not Found:
{
"jsonrpc": "2.0",
"error": {
"code": -32601,
"message": "Method not found"
},
"id": 1
}
Internal Error:
{
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "Internal error"
},
"id": 1
}
Best Practices
- Always check for errors in the response
- Use appropriate timeouts (30s recommended)
- Implement retry logic for transient failures
- Cache responses when appropriate
- Use batch requests to reduce latency
- Handle rate limits gracefully
Batch Requests
You can send multiple requests in a single HTTP call:
curl -X POST https://api.blockeden.xyz/base/<your-api-key> \
-H "Content-Type: application/json" \
-d '[
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
},
{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 2
}
]'
Response:
[
{
"jsonrpc": "2.0",
"result": "0x1b4",
"id": 1
},
{
"jsonrpc": "2.0",
"result": "0x9184e72a000",
"id": 2
}
]
Rate Limits
BlockEden.xyz implements the following rate limits:
- Free Tier: 100 requests/second
- Pro Tier: 1,000 requests/second
- Enterprise: Custom limits
Rate limit headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1640995200
Next Steps
- Learn about Base WebSocket Guide for real-time data
- Explore Base L2 Features Guide for Layer 2 specific functionality
- Visit BlockEden.xyz Dashboard to monitor usage