Logo
New RPC users get 35% off their first monthView the offer
RPC Assistant

What is the TON Network RPC URL and How Do You Use It?

Summary

The TON Network RPC URL is the endpoint your dApp or bot uses to communicate with the TON blockchain. This article explains the official public endpoint, how to configure it in your code, and when you should consider a managed RPC service like OnFinality for production workloads.

Quick Answer: TON RPC URL

The official public TON Network RPC URL is https://ton-rpc.onfinality.io. This HTTP endpoint lets you interact with the TON blockchain using standard JSON-RPC methods. If you're building a dApp, wallet, or bot, this is the URL you'll use to send transactions, query account states, and read blockchain data.

For production applications, relying on a public endpoint can lead to rate limiting and downtime. That's where a managed RPC service like OnFinality comes in—offering dedicated endpoints, higher throughput, and better reliability. You can explore RPC pricing and the list of supported RPC networks to find the right fit.

Decision Guide: Public Endpoint or Managed RPC?

Before you copy-paste the URL into your code, think about your use case. The public endpoint is fine for testing and small projects, but it has limitations:

  • Rate limits: Public endpoints often throttle requests, which can break your app during traffic spikes.
  • Uptime: Public endpoints may go down without warning, affecting your users.
  • Support: You have no one to contact if something goes wrong.

If you're building a production dApp, a managed RPC service like OnFinality offers:

  • Dedicated endpoints: No shared rate limits, so your traffic won't be affected by other users.
  • Higher reliability: Managed infrastructure with monitoring and failover.
  • Support: Access to a team that can help you troubleshoot.

Quick recommendation: Start with the public endpoint for development. When you're ready to launch, move to a managed RPC service to ensure uptime and performance. Check out how to choose an RPC provider for a deeper dive.

What is the TON Network?

TON (The Open Network) is a layer-1 blockchain designed for high-speed, low-cost transactions. It uses a unique sharding architecture that allows it to process millions of transactions per second. TON is closely integrated with Telegram, making it a popular choice for mini-apps, bots, and payments.

Developers interact with TON using its RPC API, which follows the JSON-RPC 2.0 standard. The RPC URL is the entry point for all requests—whether you're sending a transaction, querying a smart contract, or fetching account balances.

TON RPC Endpoint: Chain Settings at a Glance

Here are the key details you need to connect to the TON mainnet:

SettingValue
Network NameTON Mainnet
RPC URLhttps://ton-rpc.onfinality.io
TransportHTTP
Chain IDNot applicable (TON uses a different model)
Explorerhttps://tonviewer.com

Note: TON doesn't use EVM-style chain IDs. Instead, it uses a workchain and shard structure. For most developers, you'll just need the RPC URL.

How to Connect to TON RPC: Code Examples

Let's look at how to use the TON RPC URL in practice. We'll use JavaScript with the ton npm package, which is the most common way to interact with TON.

Install the SDK

npm install ton

Send a Simple Request

import { TonClient } from "ton";

const client = new TonClient({
  endpoint: "https://ton-rpc.onfinality.io",
});

async function getAccountBalance(address) {
  const balance = await client.getBalance(address);
  console.log(`Balance: ${balance}`);
}

getAccountBalance("EQD..."); // Replace with a real address

Using curl for a Raw JSON-RPC Call

If you prefer to test with curl, you can send a raw JSON-RPC request. For example, to get the masterchain info:

curl -X POST https://ton-rpc.onfinality.io \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"ton.getMasterchainInfo","params":[],"id":1}'

This will return the latest masterchain block information.

Understanding TON RPC Methods

TON RPC uses a set of methods that are different from Ethereum's. Here are some common ones:

MethodDescription
ton.getMasterchainInfoGet the latest masterchain block info
ton.getAccountStateGet the state of an account
ton.runGetMethodExecute a get-method on a smart contract
ton.sendMessageSend a message to the network

These methods allow you to build a wide range of applications, from simple balance checks to complex smart contract interactions.

Common Pitfalls and How to Avoid Them

When working with TON RPC, developers often run into a few issues:

1. Using the Wrong Endpoint

Make sure you're using the mainnet endpoint (https://ton-rpc.onfinality.io) and not a testnet one. If you're testing, you can use the TON Testnet endpoint, but don't mix them up.

2. Not Handling Errors Properly

TON RPC returns errors in a standard JSON-RPC format. Always check for the error field in the response. For example:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32000,
    "message": "Some error message"
  }
}

3. Ignoring Rate Limits

Public endpoints have rate limits. If you're making many requests, you might get 429 Too Many Requests errors. To avoid this, implement retry logic or use a managed service.

Debugging Your TON RPC Connection

If your requests are failing, here's a step-by-step debugging path:

  1. Check the URL: Ensure you're using the correct endpoint.
  2. Test with curl: Use the curl example above to see if the endpoint is reachable.
  3. Verify your payload: Make sure your JSON-RPC request is well-formed.
  4. Look at error codes: Common codes include -32601 (method not found) and -32602 (invalid params).
  5. Check network connectivity: If you're behind a firewall, the endpoint might be blocked.

If you're still stuck, consider using a dedicated node service that offers support. OnFinality's dedicated node offering gives you a private endpoint and direct access to experts.

Production Readiness Checklist

Before you deploy your TON app to production, run through this checklist:

  • Use a managed RPC service: Avoid public endpoints for critical traffic.
  • Implement retry logic: Handle transient failures gracefully.
  • Monitor your endpoints: Set up alerts for high error rates.
  • Secure your API keys: If you're using a service with API keys, keep them safe.
  • Test on testnet first: Use the TON testnet to validate your logic.

Key Takeaways

  • The official TON Network RPC URL is https://ton-rpc.onfinality.io.
  • Use the public endpoint for development, but switch to a managed service for production.
  • TON RPC uses JSON-RPC 2.0, but its methods are unique to TON.
  • Always handle errors and rate limits in your code.
  • For production, consider OnFinality's RPC service for reliability and support.

Frequently Asked Questions

What is the TON Network RPC URL?

The TON Network RPC URL is https://ton-rpc.onfinality.io. It's the endpoint you use to interact with the TON blockchain via JSON-RPC.

Is the TON RPC URL free to use?

Yes, the public endpoint is free, but it has rate limits. For higher limits, you can sign up for a paid plan on RPC pricing.

Can I use WebSocket with TON RPC?

TON RPC primarily uses HTTP. WebSocket support may be available through some providers, but it's not standard. Check with your provider for details.

How do I get a dedicated TON RPC endpoint?

You can get a dedicated TON RPC endpoint by subscribing to a dedicated node service like OnFinality's dedicated nodes. This gives you a private URL with higher throughput.

What are the rate limits for the public TON RPC endpoint?

Rate limits vary by provider. Public endpoints typically allow a limited number of requests per second. For production, consider a paid plan to avoid hitting limits.

RPC Knowledge Base

Related RPC details

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started