Connecting to Public RPCs: A Developer's Guide

RPC Gateway

To build applications on Near, developers need a way to read data from the blockchain (like checking an account balance) or write data (like sending a transaction). This is done via RPC (Remote Procedure Call) endpoints.

This guide outlines how to connect to public RPCs and best practices for managing connection limits.

Public vs. Private RPCs

The Endpoint List

For developers configuring their config.js or near-cli, here are the standard entry points:

Mainnet (Live Production)

URL: https://rpc.mainnet.near.org Network ID: mainnet

Testnet (Development Environment)

URL: https://rpc.testnet.near.org Network ID: testnet

How to Verify a Connection

You can test the status of the network using a simple cURL command in your terminal. This requests the general status of the node you are connecting to:

http post https://rpc.mainnet.near.org jsonrpc=2.0 id=dontcare method=status params:='[]'

If the node is healthy, it will return a JSON object containing the latest_block_height and sync_info. If the syncing boolean is false, the node is fully up to date and ready to accept transactions.