Alchemy provides JSON-RPC access to Polygon networks through authenticated HTTPS and WebSocket endpoints tied to an app and API key. This guide explains how the Alchemy RPC Polygon setup works, how endpoint URLs are structured, which network names to use, and what to check when connecting wallets, dApps, and backend services to Polygon mainnet or testnets.
What Alchemy RPC for Polygon Means
Alchemy RPC for Polygon is a hosted JSON-RPC service that lets applications read from and submit transactions to Polygon networks without running and maintaining their own node infrastructure. Instead of operating a Polygon node, developers create an app in the Alchemy dashboard and use the generated endpoint to send standard JSON-RPC requests.
Polygon is an EVM-compatible network, so most Ethereum tooling works with minimal changes. Libraries such as ethers.js, web3.js, viem, and Hardhat can point at an Alchemy Polygon endpoint by changing the RPC URL and, where relevant, the chain ID. The service handles node availability and synchronization so teams can focus on application logic.
Because Alchemy supports multiple chains, the key detail for this intent is selecting the Polygon network when creating or viewing an app. The endpoint hostname and path identify the network, while the API key identifies the account and app making the request.
- Hosted JSON-RPC access to Polygon mainnet and supported testnets
- Works with standard EVM tooling and JSON-RPC methods
- Authentication is handled through an app-specific API key
- No self-hosted Polygon node required
Alchemy Polygon Endpoint Structure
Alchemy endpoint URLs follow a consistent pattern that includes the network name and an API key. The exact hostname can vary by network and product, so always copy the endpoint shown in the Alchemy dashboard for the specific Polygon network you intend to use.
A typical Polygon mainnet HTTPS endpoint resembles the following pattern. Treat the API key as a secret and avoid committing it to public repositories.
- HTTPS endpoints are used for standard request-response JSON-RPC calls
- WebSocket endpoints are available for subscriptions and real-time event streams
- The API key is embedded in the URL path, so protect it like a password
- Use separate apps or keys for development and production where possible
https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY
wss://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEYPolygon Networks and Chain IDs
When configuring a wallet, dApp, or development framework, you need the correct RPC URL and chain ID for the Polygon network. Polygon mainnet uses chain ID 137. Polygon's current testnet is Amoy, which uses chain ID 80002. Older testnets such as Mumbai have been deprecated, so new projects should target Amoy for testing.
The Alchemy dashboard lists the supported Polygon networks and provides the matching endpoint for each. If you are migrating from another provider, update both the RPC URL and any hardcoded chain ID references in your configuration.
- Polygon mainnet: chain ID 137
- Polygon Amoy testnet: chain ID 80002
- Confirm the network name in the endpoint matches your intended chain
- Update chain ID settings in wallets and frameworks when switching networks
Creating an Alchemy App and API Key
To use Alchemy RPC with Polygon, sign in to the Alchemy dashboard and create a new app. Choose Polygon as the chain and select the network you need, such as mainnet or Amoy. The dashboard then generates an API key and endpoint URLs for HTTPS and WebSocket access.
API keys should be stored in environment variables rather than source code. If a key is exposed, rotate it in the dashboard and update your deployments. Alchemy may also provide separate keys or apps for different environments, which helps limit the impact of a leaked development key.
- Create an app and select Polygon as the chain
- Copy the HTTPS and WebSocket endpoints from the dashboard
- Store the API key in environment variables or a secrets manager
- Rotate keys if they are exposed or shared too broadly
Connecting Common Tools to Alchemy Polygon
Most EVM development tools accept a custom RPC URL. In Hardhat, set the Polygon network URL in the network configuration and reference an environment variable for the API key. In ethers.js or viem, create a provider or public client using the Alchemy endpoint.
For frontend applications, consider routing requests through a backend proxy so the API key is not exposed in browser code. If the key must be used client-side, restrict it where possible and monitor usage for unexpected traffic.
- Hardhat: add a Polygon network entry with the Alchemy HTTPS URL
- ethers.js: create a JsonRpcProvider with the endpoint URL
- viem: use the HTTP transport with the endpoint URL
- Frontends: consider a backend proxy to protect API keys
const { JsonRpcProvider } = require("ethers");
const provider = new JsonRpcProvider(process.env.ALCHEMY_POLYGON_URL);
const blockNumber = await provider.getBlockNumber();Testing and Troubleshooting Polygon RPC Calls
A simple way to verify an Alchemy Polygon endpoint is to send a basic JSON-RPC request such as eth_blockNumber and confirm that a hexadecimal block number is returned. If the request fails, check that the API key is correct, the endpoint matches the intended network, and the request method is supported.
Common issues include using a mainnet endpoint with a testnet chain ID, exceeding rate limits on a plan, and sending malformed JSON. Error responses from Alchemy usually include a code and message that help identify the cause. For production systems, add retries with backoff and fallback handling for transient failures.
- Verify with eth_blockNumber before integrating full application logic
- Match the endpoint network to the chain ID in your configuration
- Watch for rate-limit errors during traffic spikes
- Log JSON-RPC error codes and messages for faster debugging
curl -X POST https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'Pricing, Limits, and Operational Considerations
Alchemy offers tiered plans with different compute unit allowances and feature access. Pricing and limits can change, so review the current Alchemy pricing page and dashboard for the most accurate details before committing to a plan. Compute units are consumed differently depending on the JSON-RPC method used.
For Polygon applications, monitor request volume and method mix to understand compute unit consumption. Heavy methods such as log queries and trace calls can consume more resources than simple reads. Caching frequently requested data and batching requests where supported can reduce load.
Consider whether you need a single provider or a multi-provider setup. Some teams use a primary Alchemy endpoint with a fallback RPC provider to improve resilience. If you do, keep chain IDs and network settings consistent across providers.
- Review current plan limits and compute unit rules in the dashboard
- Monitor usage by method to find expensive call patterns
- Cache and batch requests where appropriate
- Consider a fallback provider for production resilience
Alchemy RPC Polygon Checklist
Before going live, confirm that your Polygon configuration is consistent across environments. The endpoint, chain ID, and API key should match the network you intend to use, and secrets should be managed outside source control.
Run a small set of read and write tests on Amoy before deploying to mainnet. Verify that transaction submission, receipt polling, and event subscriptions behave as expected. Keep an eye on error rates and latency after launch so you can adjust plan capacity or request patterns if needed.
- Endpoint and chain ID match the target Polygon network
- API keys stored securely and rotated when necessary
- Read, write, and subscription flows tested on Amoy
- Usage and error rates monitored after deployment