Logo
RPC Assistant

What is an ETH RPC endpoint and how do you use it?

摘要

ETH RPC (Remote Procedure Call) is the standard protocol for interacting with the Ethereum blockchain. This article explains what an ETH RPC endpoint is, how to use it with JSON-RPC methods, and how to choose a reliable provider for your dApp or infrastructure.

ETH RPC decision checklist

Before integrating an ETH RPC endpoint, evaluate these key criteria:

CriterionWhat to checkWhy it matters
Endpoint typeShared vs. dedicated nodeShared endpoints are cost-effective for low-volume apps; dedicated nodes provide consistent performance for high-throughput or latency-sensitive use cases.
Rate limitsRequests per second (RPS) and daily/monthly capsExceeding limits causes request failures; choose a plan that matches your peak traffic.
Archive dataAvailability of archive node endpointsRequired for historical state queries (e.g., eth_call with older block numbers).
WebSocket supportWSS endpoint for real-time subscriptionsEssential for dApps that need live event streams (e.g., pending transactions, logs).
Geographic distributionGlobal node locationsReduces latency for users worldwide; improves dApp responsiveness.
Uptime SLAPublished uptime guaranteesCritical for production apps; look for providers with transparent monitoring.
SecurityAPI key management, TLS, DDoS protectionProtects your endpoint from abuse and data interception.
Pricing modelPay-as-you-go vs. subscription vs. free tierAligns cost with usage; free tiers are great for prototyping but may have strict limits.
Supported methodsFull JSON-RPC API coverage (eth_, net_, web3_)Missing methods can break dApp functionality; verify archive and trace support if needed.
FailoverAutomatic retry and multi-endpoint fallbackEnsures high availability; some providers offer built-in load balancing.

What is an ETH RPC endpoint?

An ETH RPC endpoint is a URL that exposes the Ethereum JSON-RPC API, allowing external applications to read blockchain data and send transactions. Every Ethereum client (e.g., Geth, Nethermind, Erigon) implements this standard interface, so developers can interact with the network without running their own node.

RPC stands for Remote Procedure Call. In Ethereum, it uses JSON-RPC, a lightweight protocol that encodes requests and responses in JSON. The endpoint is typically an HTTP or WebSocket URL.

How to call an ETH RPC endpoint

You can call an ETH RPC endpoint using any HTTP client. Here's a curl example that gets the current block number:

curl https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Response:

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

Common methods include:

  • eth_blockNumber – current block number
  • eth_getBalance – balance of an address
  • eth_call – execute a read-only contract call
  • eth_sendRawTransaction – broadcast a signed transaction
  • eth_getLogs – retrieve event logs

For WebSocket subscriptions, connect to a WSS endpoint and send subscription requests:

{"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"],"id":1}

ETH RPC chain settings

To connect to Ethereum mainnet, you need the following chain details:

ParameterValue
Network NameEthereum Mainnet
RPC URLYour provider's endpoint
Chain ID1 (0x1)
Currency SymbolETH
Block Explorer URLhttps://etherscan.io

These settings are used when configuring wallets like MetaMask or adding the network to your dApp.

Choosing an ETH RPC provider

When selecting a provider for production, consider:

  • Shared vs. dedicated: Shared endpoints are cheaper but subject to noisy neighbors. Dedicated nodes offer isolated resources and predictable performance.
  • Rate limits: Free tiers often cap at 10-100 RPS. For high-traffic apps, look for plans with higher limits or dedicated nodes.
  • Archive data: If your dApp needs historical state (e.g., querying balances at past blocks), ensure the provider offers archive node access.
  • WebSocket: For real-time features, verify WSS support and subscription method availability.
  • Geographic coverage: Providers with multiple regions reduce latency for global users.

OnFinality offers both shared RPC endpoints and dedicated nodes for Ethereum, with support for archive data and WebSocket. Check our supported networks and pricing for details.

Common pitfalls and troubleshooting

  • Rate limiting: If you receive HTTP 429 or "rate limit exceeded" errors, reduce request frequency or upgrade your plan.
  • Incorrect chain ID: Using the wrong chain ID (e.g., 5 for Goerli instead of 1) will cause transaction failures.
  • Missing archive data: eth_call with a past block number may fail if the provider doesn't serve archive state.
  • WebSocket disconnects: Implement reconnection logic with exponential backoff.
  • JSON-RPC errors: Check the error field in responses; common codes include -32000 (server error) and -32602 (invalid params).

Key Takeaways

  • ETH RPC endpoints provide standardized access to the Ethereum blockchain via JSON-RPC.
  • Choose a provider based on rate limits, archive support, WebSocket availability, and geographic distribution.
  • For production apps, consider dedicated nodes for consistent performance and reliability.
  • Always verify chain settings (chain ID, RPC URL) to avoid network mismatches.
  • Implement error handling and retry logic to handle transient failures.

Frequently Asked Questions

What is the difference between HTTP and WebSocket RPC endpoints? HTTP endpoints are request-response based, suitable for one-off queries. WebSocket endpoints maintain a persistent connection, enabling real-time subscriptions (e.g., new blocks, pending transactions).

Can I use a free ETH RPC endpoint in production? Free endpoints are fine for prototyping and low-volume apps, but they often have strict rate limits and no SLA. For production, consider a paid plan or dedicated node.

How do I find my ETH RPC endpoint URL? Sign up with an RPC provider like OnFinality, create an API key, and use the provided endpoint (e.g., https://eth-mainnet.onfinality.io/api/v1/YOUR-KEY).

What is an archive node? An archive node stores the entire Ethereum state history, allowing queries at any past block. Full nodes only keep recent state. Archive access is needed for historical data analysis.

How do I add Ethereum mainnet to MetaMask? Open MetaMask, click the network dropdown, select "Add Network", and enter the chain details (RPC URL, Chain ID: 1, Currency: ETH). You can also use ChainList for automatic addition.

RPC 知识库

相关 RPC 内容

Network Rpc

What is a Binance Smart Chain RPC and how do I use it?

A Binance Smart Chain (BSC) RPC endpoint is the gateway for dApps and wallets to interact with the BSC network. This guide explains what BSC RPCs are,...

Network Rpc

选择 Sonic RPC 提供商时应该关注什么?

# 选择 Sonic RPC 提供商时应该关注什么? Sonic RPC 提供商之所以重要,是因为 Web3 应用依赖稳定的端点访问来进行读取、交易、仪表盘和后端工作流。正确的配置应匹配你的工作负载,支持你所需的网络和测试网,使限制可见,并在共享 RPC 不再足够时提供扩展路径。 对于 Sonic ...

Network Rpc

什么是Pichiu网络以及如何通过RPC连接?

# 什么是Pichiu网络以及如何通过RPC连接? Pichiu网络是一个专注于去中心化预言机服务的区块链项目,使智能合约能够安全地与链下数据交互。它基于Substrate构建,为数据馈送和跨链通信提供了强大的基础设施。对于在Pichiu上构建的开发者来说,可靠的RPC端点对于查询链上数据和提交交易...

Network Rpc

关于 Mantle RPC 端点,我需要了解什么?

# 关于 Mantle RPC 端点,我需要了解什么? Mantle RPC 端点之所以重要,是因为 Web3 应用程序依赖稳定的端点访问来进行读取、交易、仪表盘和后端工作流。正确的设置应匹配你的工作负载,支持你所需的网络和测试网,使限制可见,并在共享 RPC 不再足够时为你提供扩展路径。 对于 M...

Network Rpc

Polygon RPC: The Developer's Guide to Endpoints, Providers, and Best Practices

This guide covers everything you need to know about Polygon RPC endpoints: what they are, how to find reliable public and private endpoints, and how t...

Network Rpc

关于 Celo RPC 端点,我需要了解什么?

# 关于 Celo RPC 端点,我需要了解什么? Celo RPC 端点之所以重要,是因为 Web3 应用依赖稳定的端点访问来进行读取、交易、仪表盘和后端工作流。正确的设置应匹配你的工作负载,支持所需的网络和测试网,使限制可见,并在共享 RPC 不再足够时提供扩展路径。 对于 Celo 构建者、基...

永远不用担心基础设施

OnFinality 消除了 DevOps 的繁重工作,让您能够更聪明、更快地构建。

开始