Logo
RPC Assistant

How do I find and use a Polygon RPC endpoint for development?

Summary

Polygon RPC endpoints allow developers to interact with the Polygon blockchain without running their own nodes. This article covers mainnet and testnet chain settings, how to connect using common libraries, and what to look for when choosing between free public endpoints and dedicated infrastructure. OnFinality provides both public and dedicated Polygon RPC nodes to suit different workload needs.

Polygon RPC Decision Checklist

When selecting a Polygon RPC endpoint for your project, consider the following:

  • Workload type: Light queries (balances, transaction counts) may work on public endpoints. High-throughput dapps, trading bots, or data indexers should consider dedicated nodes.
  • Reliability: Public endpoints often have rate limits or occasional downtime. Review provider SLAs or test with your usage pattern.
  • WebSocket support: For real-time updates (e.g., pending transactions, event logs), ensure the endpoint offers WSS.
  • Archive & trace data: If you need historical state or debug_trace* methods, confirm the provider supports archive nodes.
  • Testnet availability: Amoy testnet is essential for development. Check that your provider includes it.

What Is a Polygon RPC Endpoint?

An RPC (Remote Procedure Call) endpoint is a URL that allows your application to send JSON-RPC requests to the Polygon blockchain. Polygon is an Ethereum-compatible sidechain with faster and cheaper transactions, making it popular for DeFi, gaming, and NFTs. By using an RPC endpoint, you can query on-chain data, submit transactions, and interact with smart contracts without running a full Polygon node yourself.


Polygon Chain Settings

Polygon Mainnet

PropertyValue
Network NamePolygon Mainnet
Chain ID137 (0x89)
CurrencyPOL (formerly MATIC)
RPC Endpointhttps://polygon.api.onfinality.io/public
WSS Endpointwss://polygon.api.onfinality.io/public/ws
Block Explorerhttps://polygonscan.com

Amoy Testnet

PropertyValue
Network NamePolygon Amoy
Chain ID80002
CurrencyPOL (test)
RPC Endpointhttps://rpc-amoy.polygon.technology
WSS Endpointwss://rpc-amoy.polygon.technology
Block Explorerhttps://amoy.polygonscan.com
Faucethttps://faucet.polygon.technology

How to Connect to Polygon Using RPC

You can interact with Polygon using any Ethereum-compatible tool. Below are examples using curl and the web3.js library.

cURL Example

curl https://polygon.api.onfinality.io/public \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Web3.js Example

const Web3 = require('web3');
const web3 = new Web3('https://polygon.api.onfinality.io/public');

web3.eth.getBlockNumber().then(console.log);

Adding Polygon to MetaMask

  1. Open MetaMask and go to Settings > Networks > Add Network.
  2. Enter the following:
  3. Click Save.

Free vs Dedicated Polygon RPC Endpoints

CriterionWhat to CheckWhy It Matters
Rate limitsRequests per second (RPS) or daily capPublic endpoints may throttle high-frequency apps
LatencyGeographic node locationCritical for time-sensitive operations like trading
UptimeHistorical availabilityProduction apps need consistent access
WebSocketWSS supportRequired for real-time event listening
Archive dataAccess to historical stateNeeded for analytics and compliance
TestnetAmoy supportDevelopment and testing depend on testnet
Custom methodseth_call, debug_trace*, etc.Some providers restrict advanced APIs
Pricing modelFree tier, pay-as-you-go, flat rateAligns with your budget and scaling plan

Public endpoints like https://polygon.api.onfinality.io/public are great for getting started and low-volume testing. However, if your application serves thousands of users or needs predictable performance, a dedicated node provides dedicated resources, higher rate limits, and configurable parameters.

OnFinality offers both shared public access and dedicated Polygon nodes. Dedicated nodes give you a private endpoint with no shared resource contention, custom configurations (e.g., archive mode, WebSocket), and the ability to scale as your project grows. You can view plans on our RPC pricing page.


Common Pitfalls and Debugging

  • Incorrect Chain ID: Using chain ID 137 for mainnet and 80002 for Amoy is critical. Errors here cause transaction rejection.
  • Rate limit exceeded: If you receive HTTP 429 errors, consider upgrading to a dedicated endpoint or adding a retry mechanism.
  • WebSocket disconnects: For high-frequency WSS apps, ensure your client implements reconnect logic.
  • Testnet tokens: Ensure you get POL test tokens from the official faucet before deploying.
  • Transaction underpriced: Polygon gas prices fluctuate. Use eth_gasPrice to estimate appropriate fees.

Key Takeaways

  • Polygon RPC endpoints enable interaction with the Polygon blockchain via JSON-RPC.
  • Mainnet chain ID is 137; Amoy testnet chain ID is 80002.
  • Public endpoints are suitable for testing and light use; dedicated nodes are better for production workloads.
  • Always verify WebSocket, archive, and trace support based on your application needs.
  • OnFinality provides both public and dedicated Polygon RPC endpoints. See our supported networks for more details.

Frequently Asked Questions

What is the difference between Polygon and Ethereum RPC? Polygon uses Ethereum-compatible JSON-RPC, so tools like web3.js work directly. Differences include chain ID (137 vs 1), gas token (POL vs ETH), and block times (~2 seconds vs ~12 seconds).

Can I use the same RPC endpoint for mainnet and testnet? No. Each network has a separate endpoint URL. Ensure you use the correct one for your environment.

How do I get POL test tokens for Amoy? Visit the official Polygon faucet at https://faucet.polygon.technology and enter your address.

What is a dedicated Polygon node? A dedicated node is a single-tenant Polygon node provisioned for your use. It offers dedicated compute resources, higher rate limits, and full control over the node configuration, including archive options.

Does OnFinality support Polygon WebSocket endpoints? Yes. OnFinality provides WSS endpoints for both public and dedicated nodes. Check the network details for the exact URL.

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