摘要
The Metis API refers to the JSON-RPC interface for the Metis Andromeda Layer 2 blockchain, an Ethereum-compatible rollup. This article covers chain configuration, essential RPC methods, how to connect wallets and dApps, and criteria for choosing a reliable RPC provider for production workloads.
Metis API Decision Checklist
Before integrating the Metis API, evaluate these criteria to ensure your infrastructure matches your workload:
| Criterion | What to check | Why it matters |
|---|---|---|
| Chain ID | 1088 (Metis Andromeda mainnet) | Wrong chain ID causes transaction rejection |
| RPC endpoint reliability | Uptime history, rate limits, failover support | Unreliable endpoints break dApps and cause user frustration |
| Archive data availability | Support for eth_getLogs and eth_call with historical blocks | Required for analytics, indexing, and event history |
| WebSocket support | WSS endpoint for real-time subscriptions | Needed for live updates in wallets and trading apps |
| Gas estimation accuracy | eth_estimateGas response consistency | Prevents transaction failures due to underpriced gas |
| Provider transparency | Published rate limits, pricing, and terms | Avoids unexpected throttling or costs |
| Testnet availability | Sepolia-based Metis testnet for development | Essential for safe testing before mainnet deployment |
What Is the Metis API?
The Metis API is the JSON-RPC interface for the Metis Andromeda blockchain, an Ethereum Layer 2 (L2) scaling solution that uses optimistic rollups. It is fully compatible with the Ethereum JSON-RPC specification, meaning any tool or library that works with Ethereum (e.g., ethers.js, web3.js, Hardhat) can connect to Metis by pointing to a Metis RPC endpoint.
Developers use the Metis API to:
- Send transactions and deploy smart contracts
- Query on-chain data such as balances, logs, and transaction receipts
- Estimate gas costs and simulate contract calls
- Subscribe to real-time events via WebSocket
Because Metis is EVM-equivalent, migrating dApps from Ethereum or other EVM chains requires minimal changes—typically just updating the RPC endpoint and chain ID.
Metis Chain Settings
To connect to Metis Andromeda, configure your wallet or application with the following parameters:
| Parameter | Value |
|---|---|
| Network Name | Metis Andromeda |
| RPC URL | (Provided by your RPC provider) |
| Chain ID | 1088 |
| Currency Symbol | METIS |
| Block Explorer | https://andromeda-explorer.metis.io |
| WebSocket URL | (Provided by your RPC provider) |
For the Metis Sepolia testnet, use chain ID 59902 and the corresponding testnet explorer.
Common RPC Methods on Metis
Since Metis is EVM-compatible, standard Ethereum JSON-RPC methods work identically. Here are the most frequently used ones:
eth_getBalance
Returns the balance of an address.
curl -X POST https://your-metis-rpc.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18", "latest"],
"id": 1
}'
eth_call
Executes a smart contract call without creating a transaction.
curl -X POST https://your-metis-rpc.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{"to": "0x...", "data": "0x..."}, "latest"],
"id": 1
}'
eth_getLogs
Retrieves event logs matching a filter. Useful for indexing token transfers or contract events.
curl -X POST https://your-metis-rpc.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"address": "0x...",
"fromBlock": "0x0",
"toBlock": "latest"
}],
"id": 1
}'
eth_estimateGas
Estimates the gas required for a transaction.
curl -X POST https://your-metis-rpc.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [{
"from": "0x...",
"to": "0x...",
"value": "0x0",
"data": "0x..."
}],
"id": 1
}'
eth_subscribe (WebSocket)
Subscribes to real-time events. Requires a WebSocket connection.
const WebSocket = require('ws');
const ws = new WebSocket('wss://your-metis-rpc.com');
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'eth_subscribe',
params: ['newHeads'],
id: 1
}));
});
ws.on('message', (data) => {
console.log(JSON.parse(data));
});
Connecting Wallets and dApps
Most EVM wallets (MetaMask, WalletConnect, etc.) allow adding custom networks. Use the chain settings table above. For programmatic access, configure your provider library:
ethers.js
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://your-metis-rpc.com', 1088);
const signer = provider.getSigner();
web3.js
import Web3 from 'web3';
const web3 = new Web3('https://your-metis-rpc.com');
Choosing a Metis RPC Provider
Public RPC endpoints (like those from Metis official docs) are suitable for testing but often have strict rate limits and no SLA. For production dApps, consider a managed RPC service that offers:
- Dedicated endpoints: Private RPC URLs with higher throughput and no shared throttling.
- Archive data: Full historical state for queries like
eth_getLogsfrom genesis. - WebSocket support: For real-time subscriptions.
- Geographic distribution: Low-latency access from multiple regions.
- Transparent pricing: Predictable costs based on usage or flat fee.
OnFinality provides RPC endpoints for Metis Andromeda and testnet, with options for public access and dedicated nodes. Check the pricing page for details.
Troubleshooting Common Issues
"Chain ID mismatch"
Ensure your wallet or application uses chain ID 1088 for mainnet and 59902 for testnet.
"Rate limit exceeded"
Public endpoints often cap requests per second. Switch to a private endpoint or upgrade your plan.
"eth_getLogs returns empty"
Verify the contract address and block range. Some providers limit the range for archive queries; use a provider with full archive support.
"WebSocket disconnects frequently"
Check your provider's WebSocket stability. Dedicated endpoints typically offer more reliable connections.
Key Takeaways
- The Metis API is fully EVM-compatible, so existing Ethereum tooling works with minimal changes.
- Chain ID 1088 is critical for Metis Andromeda; testnet uses 59902.
- Standard JSON-RPC methods like
eth_getBalance,eth_call, andeth_getLogsare used for data retrieval. - For production, choose a provider with dedicated endpoints, archive support, and WebSocket capabilities.
- OnFinality offers Metis RPC endpoints as part of its supported networks.
Frequently Asked Questions
Q: Is the Metis API the same as Ethereum's JSON-RPC? A: Yes, Metis implements the Ethereum JSON-RPC specification, so methods and parameters are identical.
Q: What is the Metis testnet RPC URL? A: The Metis Sepolia testnet uses chain ID 59902. Contact your RPC provider for the endpoint URL.
Q: Can I use Metis API for free? A: Public endpoints are available for testing, but production use requires a paid plan to avoid rate limits.
Q: Does Metis support WebSocket? A: Yes, most providers offer WSS endpoints for real-time subscriptions.
Q: How do I get a dedicated Metis RPC endpoint? A: Services like OnFinality provide dedicated nodes and RPC endpoints. Visit the networks page for details.