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

TON API: How to Choose and Use Endpoints for Mainnet and Testnet

摘要

TON API services provide HTTP and WebSocket access to the TON blockchain. Developers can choose between public endpoints, hosted APIs like TON Center and TonAPI, or dedicated node infrastructure from providers like OnFinality. This article compares available options, lists endpoint settings, and covers common setup and debugging steps.

TON API Decision Checklist

Before integrating a TON API, evaluate these criteria to match your workload:

CriterionWhat to checkWhy it matters
Read vs. write operationsDoes the provider support sending transactions, or only reads?Writing requires liteserver access or wallet integration.
Rate limitsFree tier vs. paid plan limits (requests per second).High-traffic dApps need higher limits or dedicated nodes.
Historical data depthDoes the API provide indexed history (traces, jettons, NFTs)?Indexed APIs like TON Center v3 enable rich queries without running a full node.
Proof verificationResponses include Merkle proofs for trustless verification.Liteserver-based APIs return proofs; REST APIs typically do not.
WebSocket / streamingReal-time event subscriptions (blocks, transactions).Needed for live dashboards, wallets, and notification systems.
Self-hosted optionCan you run your own API instance?For full control, deploy ton-http-api or use dedicated nodes.
Testnet supportAre testnet endpoints and faucets available?Essential for development and QA before mainnet deployment.
Pricing modelPay-as-you-go vs. monthly subscription vs. dedicated node.Variable costs scale with volume; dedicated nodes offer predictable pricing.

What Is a TON API?

TON (The Open Network) uses a custom binary protocol (ADNL) for node communication. A TON API acts as a bridge, translating standard HTTP/HTTPS requests into ADNL calls to liteservers. This allows developers to query blockchain data, send transactions, and subscribe to events using familiar REST or GraphQL interfaces.

Most TON APIs are built on top of the open-source ton-http-api project, which can also be self-hosted. The main differences between providers lie in indexing, rate limits, reliability, and added services like webhooks or SDKs.

TON API Providers: Main Options

1. TON Center

TON Center offers two API versions:

  • v2: Direct liteserver proxy – supports proofs, but no indexing. Good for simple reads and writes.
  • v3: Indexed database – enables rich queries for jettons, NFTs, traces, and historical data. No proof responses.

Both versions are free with an API key (up to a certain rate) and can be self-hosted. Testnet endpoints are available.

2. TonAPI (tonapi.io)

TonAPI is a SaaS platform providing REST, GraphQL, and streaming APIs. It features an integrated indexer, webhooks, and SDKs. Pricing is based on request volume, with a free tier for low usage. It does not return cryptographic proofs.

3. OnFinality TON API

OnFinality provides TON RPC endpoints as part of its multi-chain API service. You can access public endpoints or provision a dedicated node for higher reliability and rate limits. OnFinality also supports testnet and offers failover across multiple node instances. Check the pricing page for plan details.

4. Self-Hosted

Deploy the ton-http-api project on your own infrastructure. Recommended hardware: 1 vCPU, 2 GB RAM (without cache) or 2 vCPU, 4 GB RAM (with cache). You must also run a TON liteserver or connect to public liteservers.

TON API Endpoints: Mainnet and Testnet Settings

Below are common endpoints. Always verify the latest URLs in the official documentation.

ProviderMainnet EndpointTestnet EndpointNotes
TON Center (v2)https://toncenter.com/api/v2/https://testnet.toncenter.com/api/v2/Requires API key.
TON Center (v3)https://toncenter.com/api/v3/https://testnet.toncenter.com/api/v3/Indexed queries.
TonAPIhttps://tonapi.io/Not publicly documentedUse TonAPI console.
OnFinalitySee TON network pageSee TON testnet pageAPI key or IP whitelist.

Chain ID (workchain): 0 for basechain, -1 for masterchain.

Getting Started: Faucet and First Request

Testnet Faucet

Use the TON testnet faucet to receive free test coins. Common faucets:

Example: Retrieve Account Balance via TON Center v2

curl -X GET "https://toncenter.com/api/v2/getAddressBalance?address=EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N&api_key=YOUR_API_KEY"

If successful, response:

{"ok":true,"result":"5000000000"}

Using OnFinality TON API

After obtaining an API key from OnFinality, you can make requests to the provided endpoint. For example:

curl -X POST "https://ton-mainnet.onfinality.io/api/v2/" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"method":"getAddressBalance","params":{"address":"EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"}}'

Common Pitfalls and Debugging

  • Rate limiting: Public endpoints (no key) are heavily rate-limited. Always register for an API key. For production, consider dedicated infrastructure.
  • Missing proofs: If your use case requires trustless verification, use a liteserver-based API (TON Center v2, self-hosted ton-http-api). Indexed APIs (v3, TonAPI) do not return proofs.
  • Workchain confusion: Most user addresses are in workchain 0. Masterchain addresses start with -1: and require special handling.
  • Transaction submission: To send transactions, you must serialize the message externally and pass it as a base64 or hex string. Most APIs provide a /sendBoc endpoint for this.
  • CORS issues: If calling from a browser, ensure the API supports CORS or use a backend proxy.

Key Takeaways

  • TON APIs abstract the low-level ADNL protocol, offering HTTP/JSON access.
  • Choose between direct liteserver proxies (proofs, no indexing) and indexed APIs (rich queries, no proofs).
  • For production workloads, evaluate rate limits, historical depth, and failover support. Dedicated nodes or multi-provider setups improve reliability.
  • Testnet endpoints and faucets are essential for development. Always verify compatibility with your tools (e.g., wallet SDKs).
  • OnFinality provides TON RPC endpoints and dedicated nodes with flexible pricing and global coverage.

Frequently Asked Questions

Q: What is the difference between TON Center v2 and v3? A: v2 is a direct liteserver proxy that returns Merkle proofs; v3 uses an indexed database for richer queries but does not return proofs. Choose v2 if you need verifiable responses, v3 for complex data retrieval.

Q: Can I use a TON API without an API key? A: Yes, but rate limits are very low (e.g., 1 request/second). Register for a free key to increase limits.

Q: How do I send a transaction via TON API? A: Use the sendBoc endpoint with a serialized message in base64 or hex. Example: POST /api/v2/sendBoc with body {"boc":"te6cck..."}.

Q: Does OnFinality support TON testnet? A: Yes, OnFinality provides TON testnet endpoints. See the network page for details.

Q: What is the TON mainnet chain ID? A: The workchain ID is typically 0 for basechain, -1 for masterchain. There is no separate chain ID like EVM chains; the network is identified by the global config.

RPC 知识库

相关 RPC 内容

RPC 提供商选择

Chainstack vs Other RPC Providers: What to Evaluate Before Choosing

A practical comparison guide for developers evaluating Chainstack against other RPC providers. Covers key criteria including pricing models, network s...

区块链基础设施Base

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

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

网络 RPCBifrost

Bifrost RPC 端点:链设置、提供商选项和开发者配置

Bifrost 是一个兼容 EVM 的 Layer 1 区块链,具有质押流动性协议。本文涵盖 Bifrost 主网和测试网 RPC 端点、链设置、如何选择 RPC 提供商以及常见的开发者配置步骤。...

网络 RPCCelo

Celo 主网和测试网的 RPC 端点是什么?

Celo RPC 端点允许开发者连接到 Celo 区块链。主网链 ID 为 42220,测试网(Celo Sepolia)链 ID 为 11142220。存在免费的公共端点,但有速率限制;对于生产应用,请考虑使用如 OnFinality 等专用 RPC 提供商。...

网络 RPCBNB Chain

Binance Smart Chain 开发者需要了解什么?

Binance Smart Chain (BSC) 是一条兼容 EVM 的区块链,提供低费用和快速出块时间。开发者可以使用 Solidity、Hardhat 和标准的以太坊工具来构建 dApp。本文涵盖链基础知识、RPC 端点设置、智能合约部署以及选择基础设施的关键考虑因素。...

RPC 提供商选择

PublicNode 速率限制:预期与规划指南

PublicNode 为许多链提供免费的 RPC 端点,但像大多数公共服务一样,它应用速率限制以保护共享基础设施。本文解释了这些限制通常如何工作、如何检测它们,以及何时为生产工作负载迁移到专用或商业 RPC 提供商。...

永远不用担心基础设施

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

开始