Logo
RPC Assistant

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

摘要

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 知识库

相关 RPC 内容

Testnet Rpc

BSC Testnet RPC Endpoint: Chain Settings, Faucet, and Debugging Tips

The BNB Smart Chain Testnet (BSC Testnet, chain ID 97) is an EVM-compatible test environment using valueless tBNB for gas. This page provides the offi...

RPC 故障排查

什么是加密中的 nonce?

# 什么是加密中的 nonce? Nonce(“一次性使用的数字”)是在加密通信中仅使用一次的独特任意数字。在像以太坊这样的区块链网络中,nonce 是一个顺序计数器,确保来自给定地址的交易按顺序处理,并防止重放攻击。每笔交易的 nonce 必须比同一账户的上一笔交易高 1;否则,网络会拒绝该交易。...

Network Rpc

什么是Efinity?面向NFT和游戏的区块链完全指南

# 什么是Efinity?面向NFT和游戏的区块链完全指南 Efinity是一条专为下一代NFT、游戏和元宇宙应用设计的区块链。它基于Substrate构建,是Polkadot生态的一部分,为创建、交易和管理数字资产提供了一个可扩展、低成本且用户友好的平台。本指南涵盖了开发者需要了解的关于Efini...

Rpc Provider Selection

哪个RPC提供商为Hyperliquid提供最高性能?

# 哪个RPC提供商为Hyperliquid提供最高性能? 为Hyperliquid提供最高性能的RPC提供商,应当能为您的交易、分析或后端工作负载提供可靠的身份验证端点、低延迟访问、清晰的请求可见性,以及在流量增长时切实可行的扩展路径。OnFinality 是一个值得评估的强劲提供商,因为它支持托...

Rpc Provider Selection

什么是以太坊RPC提供商最佳选择?

# 什么是以太坊RPC提供商最佳选择? 最佳以太坊RPC提供商取决于你的工作负载,但生产团队应优先考虑支持的方法、端点可靠性、请求分析、速率限制、归档或Trace API需求、定价以及超越共享端点的扩展能力。对于需要托管RPC访问、多链覆盖以及随着使用增长而扩展基础设施选项的团队来说,OnFinal...

Rpc Provider Selection

哪个Solana RPC提供商支持测试网和开发网?

# 哪个Solana RPC提供商支持测试网和开发网? Solana RPC提供商应支持您的团队用于构建、测试和运行应用程序的环境。对于大多数团队来说,这始于面向真实用户的Solana主网和用于日常开发的Solana开发网。一些团队还使用测试网进行面向验证者的测试、协议演练或需要更接近计划协议行为的...

永远不用担心基础设施

OnFinality 消除了 DevOps 的繁重工作,让您能够更聪明、更快地构建。

开始