Polygon - Ethereum-Compatible Layer 2 Scaling Solution
Polygon RPC
With Dwellir, you get access to our global Polygon network which always routes your API requests to the nearest available location, ensuring low latency and the fastest speeds.
Why Build on Polygon?
Polygon is a leading Ethereum scaling solution, providing a framework for building and connecting Ethereum-compatible blockchain networks. Built with Proof of Stake consensus, Polygon offers:
🚀 Lightning Fast Performance
- 2 second block times - Fast transaction confirmations
- Up to 65,000 TPS - Massive throughput capacity
- $0.01 average transaction cost - 10,000x cheaper than Ethereum
🛡️ Enterprise Security
- 100+ validators - Highly decentralized network
- $2B+ staked - Strong economic security
- Battle-tested since 2020 - Processing billions of transactions
🌍 Massive Ecosystem
- 50M+ unique addresses - One of the largest L2 user bases
- 7,000+ dApps - Comprehensive DeFi, Gaming, and NFT ecosystem
- Major integrations - Aave, Uniswap, OpenSea, Chainlink
Quick Start with Polygon
Connect to Polygon in seconds with Dwellir's optimized endpoints:
🔗 RPC Endpoints
https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY
Quick Connect:
curl -X POST https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Installation & Setup
- ethers.js v6
- web3.js
- viem
import { JsonRpcProvider } from 'ethers';
// Connect to Polygon via Dwellir
const provider = new JsonRpcProvider(
'https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY'
);
// Test connection
const blockNumber = await provider.getBlockNumber();
console.log('Connected to Polygon at block:', blockNumber);
import Web3 from 'web3';
// Initialize Web3 with Dwellir endpoint
const web3 = new Web3(
'https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY'
);
// Verify connection
const chainId = await web3.eth.getChainId();
console.log('Connected to Polygon (Chain ID:', chainId, ')');
import { createPublicClient, http } from 'viem';
import { polygon } from 'viem/chains';
const client = createPublicClient({
chain: polygon,
transport: http('https://api-polygon-mainnet-full.n.dwellir.com/YOUR_API_KEY'),
});
const blockNumber = await client.getBlockNumber();
console.log('Current block:', blockNumber);
Available Methods
Available JSON-RPC Methods
📊 Reading Blockchain Data
Query blocks, transactions, and account states
📤 Sending Transactions
Submit and manage transactions
📝 Smart Contract Interaction
Call and interact with smart contracts
🔧 Node & Network Info
Query node status and network information
🎯 Polygon Specific
Methods specific to Polygon PoS
Ready to integrate Polygon into your dApp?
Get Your Free API Key →Core JSON-RPC Methods
Essential methods for interacting with the Polygon network:
Method | Description | Link |
---|---|---|
eth_blockNumber | Get the latest block number | View docs → |
eth_getBalance | Query MATIC/POL balance of an address | View docs → |
eth_getBlockByNumber | Retrieve block details by number | View docs → |
eth_call | Execute smart contract calls | View docs → |
eth_getTransactionByHash | Get transaction details | View docs → |
eth_getTransactionReceipt | Fetch transaction receipts | View docs → |
eth_sendRawTransaction | Broadcast signed transactions | View docs → |
eth_estimateGas | Estimate gas for transactions | View docs → |
eth_gasPrice | Get current gas price | View docs → |
eth_getLogs | Query event logs | View docs → |
Debug & Trace Methods
Advanced methods for debugging and analyzing transactions:
Method | Description | Link |
---|---|---|
debug_traceTransaction | Detailed transaction execution trace | View docs → |
debug_traceBlock | Trace all transactions in a block | View docs → |
debug_traceBlockByNumber | Trace block by number | View docs → |
Network Information
Chain Details
Parameter | Mainnet | Testnet (Amoy) |
---|---|---|
Chain ID | 137 | 80002 |
Currency | MATIC (transitioning to POL) | MATIC |
Block Time | ~2 seconds | ~2 seconds |
Block Gas Limit | 30M | 30M |
RPC Endpoint | https://api-polygon-mainnet-full.n.dwellir.com | https://api-polygon-amoy.n.dwellir.com |
Important Addresses
Contract | Address |
---|---|
WMATIC | 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270 |
USDC | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
USDT | 0xc2132D05D31c914a87C6611C10748AEb04B58e8F |
Multicall3 | 0xcA11bde05977b3631167028862bE2a173976CA11 |
Best Practices
1. Optimize Gas Usage
Polygon has low fees, but optimizing gas usage is still important:
// Use gas estimation for accurate pricing
const gasEstimate = await contract.estimateGas.transfer(to, amount);
const gasPrice = await provider.getGasPrice();
const txCost = gasEstimate * gasPrice;
2. Handle Network Congestion
Monitor and adapt to network conditions:
// Implement dynamic gas pricing
const gasPrice = await provider.getGasPrice();
const adjustedGasPrice = gasPrice * 110n / 100n; // 10% buffer
3. Leverage Polygon's Speed
Take advantage of fast block times for better UX:
// Quick confirmation monitoring
const tx = await wallet.sendTransaction(transaction);
const receipt = await tx.wait(1); // Usually confirms in 1 block (~2 seconds)
Resources
- Official Polygon Documentation
- Polygon Network Explorer
- Polygon Developer Portal
- Get Your Dwellir API Key
Support
Need help? Our team is available 24/7:
- Email: support@dwellir.com
- Documentation: You're already here!
Start building on Polygon with Dwellir's enterprise-grade infrastructure today.