Resumen
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
| Property | Value |
|---|---|
| Network Name | Polygon 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/ws |
| Block Explorer | https://polygonscan.com |
Amoy Testnet
| Property | Value |
|---|---|
| Network Name | Polygon Amoy |
| Chain ID | 80002 |
| Currency | POL (test) |
| RPC Endpoint | https://rpc-amoy.polygon.technology |
| WSS Endpoint | wss://rpc-amoy.polygon.technology |
| Block Explorer | https://amoy.polygonscan.com |
| Faucet | https://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
- Open MetaMask and go to Settings > Networks > Add Network.
- Enter the following:
- Network Name: Polygon Mainnet
- New RPC URL: https://polygon.api.onfinality.io/public
- Chain ID: 137
- Currency Symbol: POL
- Block Explorer URL: https://polygonscan.com
- Click Save.
Free vs Dedicated Polygon RPC Endpoints
| Criterion | What to Check | Why It Matters |
|---|---|---|
| Rate limits | Requests per second (RPS) or daily cap | Public endpoints may throttle high-frequency apps |
| Latency | Geographic node location | Critical for time-sensitive operations like trading |
| Uptime | Historical availability | Production apps need consistent access |
| WebSocket | WSS support | Required for real-time event listening |
| Archive data | Access to historical state | Needed for analytics and compliance |
| Testnet | Amoy support | Development and testing depend on testnet |
| Custom methods | eth_call, debug_trace*, etc. | Some providers restrict advanced APIs |
| Pricing model | Free tier, pay-as-you-go, flat rate | Aligns 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_gasPriceto 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.