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.
Thanks @<1485644594262577152|Tal Kol> for clarify!