TLDR
For most cases https://www.orbs.com/ton-access is a good solution for getting unthrottled and decentralized RPC access
It also has convenient JS API:
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { TonClient } from "ton";
// get the decentralized RPC endpoint
const endpoint = await getHttpEndpoint();
// initialize ton library
const client = new TonClient({ endpoint });
Longer answer
It depends on your use-case. There are three primary use-cases for using RPC:
-
You want to experiment as a developer, learn and play. You will make a small number of calls. For this TON Access is probably the best because you don't need to register and it's reliable.
-
You're building a production dapp and your web client needs to make RPC calls like calling getters. For this TON Access is the best because that's why it was made. Your dapp users are anonymous and this is the only service that will not throttle them by declaration since they don't have API keys.
-
You build a production backend that needs to make many calls to the chain. For example, you build an indexing service that shows all holders of a Jetton so to index the data in your backend you need RPC. For this TON Access is not good at all and you're better with services like TonCenter or TonApi. These services will require that you register an API key which makes sense since you're a heavy user.
Don't run your own RPC
If you're building a centralized service then run your own RPC. But if you're building a decentralized service like a dapp, relying on a server that you run by yourself is too centralized and considered bad practice.
Be aware of multiple RPC protocols
Unlike Ethereum, TON doesn't have a single RPC protocol that everybody uses. There are currently 3 different RPC protocols people use:
- HTTP API V2 created by TonCenter
- HTTP API V4 created by TonWhales
- Raw ADNL over HTTP
TON Access is curently the only RPC providers that support all 3 protocols.
Please note that TonApi is a centralized indexed service and not RPC. For decentralized apps you need your blockchain queries to be routed to full nodes or validator nodes. This doesn't happen with TonApi since it has special indexes that TON full nodes and validator nodes don't support.
Disclosure
I helped build TON Access. The reason I built it because there was no decentralized RPC provider for dapps in the ecosystem and I think such a thing is important.
First of all, what is your usage for the RPC endpoint you want?
To obtain an RPC endpoint for the TON network, you can either run your own node or use a public node run by a third party. To run your own node, you will need to download and set up the TON software, which can be obtained from the official TON GitHub repository. For public nodes, you can check websites such as TON Labs or search for TON nodes on popular forums.
Documentation for the TON network, including information on the RPC API, can be found in the TON Developers section of the TON Labs website and on the official TON GitHub repository.
https://github.com/ton-core
https://github.com/ton-community
Please note that TonApi (https://tonapi.io/) is a centralized indexed service and not RPC. For decentralized apps you need your blockchain queries to be routed to full nodes or validator nodes. This doesn't happen with TonApi since it has special indexes that TON full nodes and vliadator nodes don't support.