Documentation Index
Fetch the complete documentation index at: https://polynode.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Endpoint
https://rpc.polynode.dev
x-api-key header or Authorization: Bearer header.
Integration Examples
- viem
- ethers.js
- web3.py
- curl
import { createPublicClient, createWalletClient, http } from 'viem'
import { polygon } from 'viem/chains'
import { privateKeyToAccount } from 'viem/accounts'
const transport = http('https://rpc.polynode.dev', {
fetchOptions: {
headers: { 'x-api-key': 'YOUR_API_KEY' }
}
})
// Read contract state
const publicClient = createPublicClient({
chain: polygon,
transport
})
const blockNumber = await publicClient.getBlockNumber()
const balance = await publicClient.getBalance({
address: '0xYOUR_ADDRESS'
})
// Send transactions with priority routing
const account = privateKeyToAccount('0xYOUR_PRIVATE_KEY')
const walletClient = createWalletClient({
account,
chain: polygon,
transport
})
const hash = await walletClient.sendTransaction({
to: '0xRECIPIENT',
value: parseEther('1.0')
})
import { ethers } from 'ethers'
const provider = new ethers.JsonRpcProvider(
'https://rpc.polynode.dev',
137,
{ staticNetwork: true }
)
// Add auth to every request
const originalSend = provider.send.bind(provider)
provider.send = async (method, params) => {
const resp = await fetch('https://rpc.polynode.dev', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({ jsonrpc: '2.0', method, params, id: 1 })
})
const { result, error } = await resp.json()
if (error) throw new Error(error.message)
return result
}
const blockNumber = await provider.getBlockNumber()
const balance = await provider.getBalance('0xYOUR_ADDRESS')
// Send a transaction
const wallet = new ethers.Wallet('YOUR_PRIVATE_KEY', provider)
const tx = await wallet.sendTransaction({
to: '0xRECIPIENT',
value: ethers.parseEther('1.0')
})
from web3 import Web3
w3 = Web3(Web3.HTTPProvider(
'https://rpc.polynode.dev',
request_kwargs={
'headers': {'x-api-key': 'YOUR_API_KEY'}
}
))
# Read state
block = w3.eth.block_number
balance = w3.eth.get_balance('0xYOUR_ADDRESS')
# Check token balance (USDC)
usdc = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359'
data = '0x70a08231' + '0xYOUR_ADDRESS'[2:].lower().zfill(64)
result = w3.eth.call({'to': usdc, 'data': data})
usdc_balance = int(result.hex(), 16) / 1e6
# Send a transaction
account = w3.eth.account.from_key('YOUR_PRIVATE_KEY')
tx = {
'nonce': w3.eth.get_transaction_count(account.address),
'to': '0xRECIPIENT',
'value': w3.to_wei(1, 'ether'),
'gas': 21000,
'gasPrice': w3.eth.gas_price,
'chainId': 137,
}
signed = account.sign_transaction(tx)
tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction)
# Check block number
curl -X POST https://rpc.polynode.dev \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
# Check MATIC balance
curl -X POST https://rpc.polynode.dev \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":["0xYOUR_ADDRESS","latest"],
"id":1
}'
# Send a signed transaction
curl -X POST https://rpc.polynode.dev \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"jsonrpc":"2.0",
"method":"eth_sendRawTransaction",
"params":["0xSIGNED_TX_HEX"],
"id":1
}'
Hardhat / Foundry
- Hardhat
- Foundry
// hardhat.config.js
module.exports = {
networks: {
polygon: {
url: 'https://rpc.polynode.dev',
accounts: [process.env.PRIVATE_KEY],
chainId: 137,
httpHeaders: {
'x-api-key': process.env.POLYNODE_API_KEY
}
}
}
}
# Set auth via header
export ETH_RPC_URL=https://rpc.polynode.dev
# Deploy
forge script script/Deploy.s.sol \
--rpc-url $ETH_RPC_URL \
--broadcast \
--private-key $PRIVATE_KEY
# Read state
cast call 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 \
"totalSupply()" \
--rpc-url $ETH_RPC_URL
Response Format
Standard Ethereum JSON-RPC responses:// Success
{"jsonrpc": "2.0", "id": 1, "result": "0x..."}
// Error
{"jsonrpc": "2.0", "id": 1, "error": {"code": -32000, "message": "..."}}

