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 内容

区块链基础设施Base

什么是 Base 节点基础设施,何时应该运行自己的节点?

Base 节点基础设施是指运行 Base 节点所需的硬件、软件和网络设置,包括执行客户端、共识客户端以及与网络的同步。运行自己的节点可以直接访问链,无需依赖第三方 RPC 提供商,但需要大量的运维工作。对于大多数生产级应用,使用像 OnFinality 这样的托管 RPC 服务,在可靠性、可扩展性和...

网络 RPCBNB Chain

Binance Chain API:如何连接 BNB 智能链 RPC 端点

了解如何使用 RPC API 连接 BNB 智能链(Binance Chain)。本指南涵盖链设置、公共端点,以及如何为您的 dApp 选择公共、托管或专用节点基础设施。...

网络 RPCOptimism

Optimism Nodes: Public, Managed, or Self-Hosted?

Optimism nodes are the software clients that let you read and write data on OP Mainnet, the leading Ethereum Layer 2. You can run your own node for fu...

网络 RPCSolana

Solana RPC 端点:如何连接、配置和调试

Solana RPC 端点是您的 dApp 或验证器用来向 Solana 网络发送 JSON-RPC 请求的 URL。本页介绍主网和开发网端点、如何在代码中配置它们,以及如何调试常见的连接问题。对于生产环境的工作负载,OnFinality 提供的托管或专用 RPC 端点可提供可靠性和可扩展性。...

网络 RPCBittensor

Bittensor 主网、Lite 和测试网的 RPC URL 是什么?

Bittensor 为不同的网络层级提供多个 RPC 端点:Finney(主网)位于 `wss://entrypoint-finney.opentensor.ai:443`,Lite(EVM 兼容)位于 `https://lite.chain.opentensor.ai`,测试网位于 `https:...

网络 RPCBNB Chain

什么是BNB节点,什么时候应该运行一个?

BNB节点是存储BNB智能链状态并处理交易的客户端。运行一个节点可以让您直接访问链,但需要大量的硬件和维护。对于大多数应用程序,像OnFinality这样的托管RPC服务提供了一种更实用的方式来与BNB链交互,而无需承担运营开销。...

永远不用担心基础设施

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

开始