Summary
This guide covers everything you need to know about Polygon RPC endpoints: what they are, how to find reliable public and private endpoints, and how to choose the right provider for your dApp. Whether you're building on Polygon PoS mainnet or testing on Amoy, you'll get practical advice on performance, rate limits, and troubleshooting common issues.
Polygon RPC decision checklist
Before you integrate a Polygon RPC endpoint, evaluate these factors to avoid common pitfalls:
| Criterion | What to check | Why it matters |
|---|---|---|
| Network & Chain ID | Confirm you are using Polygon PoS mainnet (Chain ID 137) or Amoy testnet (Chain ID 80002) | Wrong chain ID can cause transaction failures or fund loss |
| Rate limits | Public endpoints often cap requests per second (e.g., 10-100 req/s) | Exceeding limits leads to 429 errors and dropped requests |
| Uptime & reliability | Check historical uptime and node redundancy | Downtime can break your dApp or cause missed blocks |
| Data freshness | Ensure the endpoint returns the latest block quickly | Stale data can lead to incorrect state reads |
| WebSocket support | Verify WSS endpoint availability for real-time subscriptions | Required for event listeners and live updates |
| Privacy & security | Public endpoints may log your IP and requests | Sensitive applications need private endpoints |
| Archive data | Do you need historical state? Archive nodes store full history | Required for certain queries like eth_getLogs over large ranges |
| Cost | Compare free vs paid tiers, and understand pricing models | Unplanned costs can blow your budget |
What is a Polygon RPC endpoint?
A Polygon RPC (Remote Procedure Call) endpoint is a URL that allows your application to communicate with the Polygon blockchain. It acts as a gateway, enabling you to send transactions, query balances, call smart contracts, and subscribe to events using standard JSON-RPC methods like eth_call, eth_getBalance, and eth_sendRawTransaction.
Polygon is an Ethereum-compatible (EVM) sidechain, so its RPC interface is nearly identical to Ethereum's. This means you can use the same Web3 libraries (ethers.js, web3.js, viem) and tools (Hardhat, Foundry, Remix) with minimal configuration changes.
Polygon network details
Polygon PoS Mainnet
- Chain ID: 137 (0x89)
- Currency: POL (formerly MATIC)
- RPC endpoint:
https://polygon.api.onfinality.io/public - WSS endpoint:
wss://polygon.api.onfinality.io/public - Block explorer: PolygonScan
Polygon Amoy Testnet
- Chain ID: 80002
- Currency: POL (testnet)
- RPC endpoint:
https://polygon-amoy.api.onfinality.io/public - WSS endpoint:
wss://polygon-amoy.api.onfinality.io/public - Block explorer: Amoy Polygonscan
- Faucet: Available via the official Polygon faucet
How to use a Polygon RPC endpoint
1. Add to MetaMask
- Open MetaMask and click the network dropdown.
- Click "Add Network" and then "Add a network manually".
- Fill in the details:
- Network Name: Polygon Mainnet
- RPC URL:
https://polygon.api.onfinality.io/public - Chain ID:
137 - Currency Symbol:
POL - Block Explorer URL:
https://polygonscan.com
- Click "Save".
2. Use with ethers.js
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("https://polygon.api.onfinality.io/public");
const blockNumber = await provider.getBlockNumber();
console.log("Current block:", blockNumber);
3. Use with curl
curl -X POST https://polygon.api.onfinality.io/public \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Public vs private Polygon RPC endpoints
Public endpoints
Public RPC endpoints are free and easy to use. They are great for prototyping, small projects, and personal use. However, they come with limitations:
- Rate limits: Typically 10-100 requests per second. Exceeding these limits results in HTTP 429 errors.
- No reliability expectations: Public nodes can go offline without notice.
- No privacy: Your IP address and request data are visible to the node operator.
- Limited data: Some public endpoints do not support archive data or debug/trace methods.
Popular public Polygon RPC endpoints include:
https://polygon.api.onfinality.io/publichttps://polygon-bor-rpc.publicnode.comhttps://polygon.drpc.orghttps://1rpc.io/matic
Private endpoints
Private (or dedicated) endpoints are provisioned for your exclusive use. They offer:
- Higher rate limits: Customizable to your needs, often thousands of requests per second.
- Better reliability: Redundant infrastructure with SLAs.
- Enhanced privacy: Your requests are not shared with other users.
- Full API access: Support for archive data, debug/trace methods, and custom configurations.
Providers like OnFinality offer dedicated Polygon nodes that can be tailored to your application's requirements. You can choose between shared and dedicated infrastructure depending on your scale and budget.
Common issues and troubleshooting
429 Too Many Requests
This error indicates you have exceeded the rate limit of the endpoint. Solutions:
- Reduce request frequency: Implement exponential backoff or batch requests.
- Upgrade to a private endpoint: Private endpoints offer higher or clear rate limits.
- Use multiple endpoints: Distribute requests across several public endpoints (but be aware of data consistency).
Connection timeouts
Timeouts can occur due to network congestion or node overload. Try:
- Switching to a different endpoint from the list above.
- Using a WebSocket endpoint for real-time subscriptions (more efficient for event-driven apps).
- Contacting your provider if the issue persists.
Stale data
If you receive outdated block data, the node may be lagging. Verify the latest block number using a block explorer. For production, use endpoints with proven low latency.
How to choose a Polygon RPC provider
When selecting a provider for your Polygon dApp, consider the following:
- Performance: Look for low latency and high throughput. Test endpoints with tools like
curlorwscat. - Reliability: Check uptime history and whether the provider offers redundant nodes.
- Scalability: Ensure the provider can handle your peak request volume without degradation.
- Support: Evaluate the quality of documentation and technical support.
- Pricing: Compare free tiers, pay-as-you-go, and dedicated plans. See RPC pricing for details.
- Network coverage: Does the provider support both mainnet and testnet? OnFinality supports Polygon mainnet and Amoy testnet.
Key Takeaways
- Polygon RPC endpoints allow your dApp to interact with the Polygon blockchain using standard JSON-RPC.
- Public endpoints are free but come with rate limits and no guarantees; private endpoints offer better performance and reliability.
- Always verify the network (mainnet vs testnet) and chain ID to avoid costly mistakes.
- For production applications, consider using a dedicated node or a premium RPC service to ensure uptime and scalability.
- Test your endpoint thoroughly before deploying to production.
Frequently Asked Questions
Q: What is the difference between Polygon RPC and Ethereum RPC?
A: Polygon is EVM-compatible, so the RPC interface is nearly identical. The main differences are the chain ID (137 vs 1) and the underlying consensus mechanism (Polygon uses a modified Proof-of-Stake with Bor and Heimdall layers).
Q: Can I use a free Polygon RPC for production?
A: It depends on your traffic. Free public endpoints are suitable for low-volume applications and testing. For production with high traffic, a private endpoint is recommended to avoid rate limits and downtime.
Q: How do I get a Polygon RPC URL?
A: You can use public endpoints listed in this guide, or sign up with a provider like OnFinality to get a dedicated endpoint. See supported RPC networks for more options.
Q: What is the Polygon Amoy testnet RPC?
A: The Amoy testnet RPC endpoint is https://polygon-amoy.api.onfinality.io/public with Chain ID 80002. It is used for testing before deploying to mainnet.
Q: How do I check my Polygon RPC endpoint is working?
A: Use curl to send a simple eth_blockNumber request. If you get a valid JSON response with a block number, the endpoint is working.
Q: What are the rate limits for public Polygon RPC?
A: Rate limits vary by provider. Typically, public endpoints allow 10-100 requests per second. Check the provider's documentation for exact limits.
Q: Can I use WebSocket with Polygon RPC?
A: Yes, many providers offer WebSocket endpoints (e.g., wss://polygon.api.onfinality.io/public). WebSocket is recommended for real-time subscriptions.
Q: What is the best Polygon RPC provider?
A: The best provider depends on your needs. For a balance of performance, reliability, and pricing, consider OnFinality. Evaluate multiple providers using the checklist above.
Q: How do I add Polygon to MetaMask?
A: Use the network details provided in this guide (Chain ID 137, RPC URL, etc.) and add it manually in MetaMask's network settings.
Q: What is the difference between Polygon PoS and Polygon zkEVM?
A: Polygon PoS is a sidechain with its own validator set, while Polygon zkEVM is a zero-knowledge rollup that inherits security from Ethereum. They have different RPC endpoints and chain IDs.