Logo
新用户订阅 RPC,首月享 6.5 折优惠查看优惠
RPC Assistant

What Is Stellar RPC and How to Use It for Your dApp?

摘要

Stellar RPC refers to the remote procedure call interface that allows applications to interact with the Stellar blockchain. Unlike Ethereum, Stellar uses a different API called Horizon, which provides RESTful endpoints for querying the ledger, submitting transactions, and managing accounts. For developers, finding a reliable Stellar RPC provider is key to building production dApps without running full nodes. OnFinality offers Stellar RPC endpoints that abstract infrastructure complexity, giving you scalable access to the Stellar network.

When choosing a Stellar RPC provider, consider factors like rate limits, uptime, and support for Horizon-specific features like streaming endpoints. OnFinality provides both shared and dedicated Stellar nodes, with transparent pricing and multi-region availability, making it a strong choice for developers scaling their Stellar projects.

Stellar RPC Decision Checklist

Before integrating Stellar RPC into your project, evaluate the following points:

  • Horizon vs. Core API: Stellar's primary RPC interface is Horizon, a RESTful API. Ensure your provider offers full Horizon coverage, including streaming endpoints.
  • Rate limits: Check free tier limits and whether paid plans scale with your transaction volume.
  • Network support: Confirm availability for both Stellar Mainnet and Testnet (including the SDF testnet).
  • Node diversity: Running a single Stellar Core node can be a single point of failure. Use a provider that offers load-balanced endpoints.
  • Latency and region: If your dApp is global, choose a provider with multi-region endpoints to reduce latency.
  • Dev tooling: Some providers offer Horizon-specific debugging features like transaction simulation and fee estimation.

What Is Stellar RPC?

Stellar RPC refers to the mechanism by which external applications communicate with the Stellar blockchain. Unlike Ethereum's JSON-RPC, Stellar relies on an API layer called Horizon, which exposes RESTful endpoints for reading ledger state, submitting transactions, and managing accounts. Horizon acts as a bridge between client applications and the Stellar Core network.

If you are building a wallet, decentralized exchange, or payment app on Stellar, you will interact primarily through Horizon. Running your own Horizon instance requires operating a Stellar Core node and additional infrastructure — which many teams prefer to outsource to a managed RPC provider like OnFinality.

Stellar RPC Endpoints and Network Settings

Stellar provides two primary networks: Mainnet and Testnet. The Testnet is ideal for development and testing, while Mainnet handles real assets.

NetworkHorizon URLNetwork Passphrase
Mainnethttps://horizon.stellar.orgPublic Global Stellar Network ; September 2015
Testnethttps://horizon-testnet.stellar.orgTest SDF Network ; September 2015

When using a managed provider like OnFinality, you will receive a custom endpoint that may include load balancing and caching. For example, an OnFinality Stellar endpoint might look like:

https://stellar.onfinality.io/api/v1/horizon

Always verify the exact endpoint from your provider's dashboard.

How to Use Stellar RPC with JavaScript

To interact with Stellar via Horizon, you typically use the stellar-sdk JavaScript library. Here is a basic example of fetching account details:

const StellarSdk = require('stellar-sdk');

// Use your provider's Horizon URL
const server = new StellarSdk.Server('https://stellar.onfinality.io/api/v1/horizon');

async function getAccount(publicKey) {
  try {
    const account = await server.loadAccount(publicKey);
    console.log('Balances:', account.balances);
  } catch (e) {
    console.error('Error loading account:', e);
  }
}

getAccount('G...');

For submitting a transaction:

const StellarSdk = require('stellar-sdk');
const server = new StellarSdk.Server('https://stellar.onfinality.io/api/v1/horizon');

async function submitTx() {
  const account = await server.loadAccount('G...');
  const transaction = new StellarSdk.TransactionBuilder(account, {
    fee: StellarSdk.BASE_FEE,
    networkPassphrase: StellarSdk.Networks.PUBLIC
  })
    .addOperation(StellarSdk.Operation.payment({
      destination: 'G...',
      asset: StellarSdk.Asset.native(),
      amount: '10'
    }))
    .setTimeout(30)
    .build();

  // Sign with your secret key (not shown for security)
  // Send to network
  const result = await server.submitTransaction(transaction);
  console.log('Transaction hash:', result.hash);
}

Stellar Faucet for Testnet

To test your dApp on the Stellar Testnet, you need free test lumens (XLM). The Stellar Development Foundation (SDF) provides a faucet:

  • Friendbot API: https://friendbot.stellar.org/?addr=YOUR_PUBLIC_KEY

Example curl request:

curl "https://friendbot.stellar.org/?addr=G..."

This will fund the account with 10,000 test XLM. Managed RPC providers may also offer their own faucet endpoints for their testnet nodes—check your provider's documentation.

Choosing a Stellar RPC Provider

While running your own Horizon + Stellar Core node is possible, most teams prefer a managed RPC provider to avoid operational overhead. Here's a comparison table to evaluate providers:

CriterionWhat to checkWhy it matters
Uptime SLAPublished uptime guarantees and compensation policiesEnsures your dApp remains available; missing SLAs indicate risk
Rate limitsRequests per second (RPS) and daily/monthly capsHigh-traffic apps need scalable limits
Endpoint diversitySupport for both Mainnet and Testnet, plus custom endpointsSimplifies development and production parity
Horizon feature setFull Horizon endpoints (payments, trades, account details)Missing endpoints break app functionality
Geo-distributionGlobal load balancing or regional optionsReduces latency for users worldwide
Streaming supportServer-sent events (SSE) for real-time updatesEssential for payment tracking and order books
Debugging toolsTransaction simulation, fee estimation endpointsSpeeds up development and error resolution

OnFinality, for example, supports Stellar with dedicated nodes and shared endpoints, offering customizable rate limits and multi-region infrastructure. You can review the full list of supported networks on our networks page and pricing.

Common Pitfalls and Debugging

  • Incorrect network passphrase: Using Mainnet passphrase on Testnet (or vice versa) causes transaction failures. Always double-check.
  • Account not funded: On Testnet, you must fund accounts via Friendbot before using them.
  • Horizon sync delay: Newly submitted transactions may take a few seconds to appear. Use streaming endpoints for real-time feedback.
  • Rate limiting: Free tiers often have low RPS. Monitor your usage and upgrade if needed.

Debugging tip: Use Horizon's transaction submission endpoint to inspect error codes. For example, a 400 response with op_underfunded means the source account lacks XLM.

Key Takeaways

  • Stellar RPC is powered by Horizon, a RESTful API that provides access to the Stellar network.
  • For production dApps, use a managed RPC provider to handle node operations, load balancing, and uptime.
  • Evaluate providers based on endpoint coverage, rate limits, geographic distribution, and support for streaming.
  • Always test on Stellar Testnet using Friendbot before deploying to Mainnet.
  • OnFinality offers Stellar RPC endpoints as part of a broader multi-chain RPC service with transparent pricing.

Frequently Asked Questions

Can I use Ethereum JSON-RPC to interact with Stellar? No. Stellar uses the Horizon REST API, not Ethereum's JSON-RPC. You must use Horizon endpoints and the stellar-sdk or raw REST calls.

Does OnFinality support Stellar Testnet? Yes, OnFinality provides endpoints for both Stellar Mainnet and Testnet. Check the network details page for exact URLs.

How do I get free XLM for testing? Use the SDF Friendbot or your provider's own faucet. OnFinality does not currently offer a faucet but supports the public Friendbot.

What are the rate limits for free Stellar RPC? Free tiers typically allow a few requests per second. For higher limits, consider a dedicated node plan. See our pricing page for details.

Can I run a dedicated Stellar node with OnFinality? Yes, OnFinality offers dedicated Stellar nodes with custom configurations and priority support.

RPC 知识库

相关 RPC 内容

区块链基础设施

Polymarket API 文档:你实际需要哪个 API?

如果你搜索了 Polymarket API 文档,你可能想做三件事之一:读取实时市场和事件数据、流式获取订单簿和交易,或者以编程方式下单和管理订单。这些任务由不同的 API 提供,最快的路径是在阅读任何端点参考之前,先确定哪个 API 与你的工作负载匹配。 在高层次上,Polymarket 的表面分...

网络 RPCEth Sepolia

如何通过 eth_getBlockByNumber 获取最新的以太坊区块?

了解如何使用 eth_getBlockByNumber JSON-RPC 方法获取最新的以太坊区块,包括 curl 和 ethers.js 示例、响应字段和常见陷阱。比较公共、托管和专用 RPC 选项,为您的 dApp 选择合适的端点。...

网络 RPCPolygon

Polygon 速率限制:它们是什么以及如何避免 429 错误

Polygon 速率限制限制了端点在一个给定时间窗口内接受的 JSON-RPC 请求数量,当您超过限制时,会收到 HTTP 429 响应、WebSocket 订阅被丢弃或静默超时。公共端点在所有调用者之间共享这些限制,因此一个繁重的循环就可能拖垮您的整个应用。 本文解释了 Polygon 速率限制的...

区块链基础设施Bittensor

2025年Bittensor TAO挖矿:子网经济、节点设置和RPC要求

2025年的Bittensor挖矿不再是一个单一网络的活动。矿工和验证者需要在各个子网内竞争,每个子网都有自己的激励机制、模型类型和注册成本,因此实际问题是哪个子网能让你盈利,以及该子网需要什么样的基础设施。本文详细介绍了关键决策:选择子网、确定硬件规模、注册热键和冷键,以及如何将你的矿工进程可靠地...

RPC 提供商选择Ethereum

2025年最佳以太坊RPC性能监控服务

以太坊RPC端点的性能监控意味着跟踪延迟、错误率、吞吐量以及随时间变化的方法级行为。本文解释了要测量什么、如何构建监控探针,以及如何评估RPC提供商的可观测性,包括OnFinality的以太坊RPC服务。...

网络 RPCAvalanche

Base Network RPC:如何连接以及应使用哪个端点?

Base 是基于 OP Stack 构建的以太坊 Layer 2,因此其 RPC 接口与以太坊工具链兼容 JSON-RPC。您只需将客户端指向链 ID 为 8453 的 Base 端点即可连接,大多数以太坊库几乎无需修改或只需少量修改即可使用。主要决策在于选择哪个端点、如何处理速率限制,以及如何在流...

永远不用担心基础设施

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

开始