Optimism
Optimism
Optimism
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
https://optimism.therpc.io/YOUR_API_KEY and the Authorization: Bearer header.https://optimism.therpc.io/YOUR_API_KEY) for single, stateless requests and simple integrations. Use the WebSocket endpoint (wss://optimism.therpc.io/YOUR_API_KEY) for real-time subscriptions via eth_subscribe, such as streaming new ~2-second blocks instead of polling.OP Mainnet returns standard JSON-RPC error codes, summarized in the table below: -32700 for a parse error, -32600 for an invalid request, -32601 for a method that isn't found, -32602 for invalid params, -32603 for an internal error, and the -32000 to -32099 range for server errors. Four habits make error handling reliable: always check the error field before reading result, retry transient failures with exponential backoff, log the full error code and message for diagnosis, and set sensible timeouts so a slow request doesn't hang your application.
| Code | Meaning |
|---|---|
-32700 | Parse error |
-32600 | Invalid request |
-32601 | Method not found |
-32602 | Invalid params |
-32603 | Internal error |
-32000 to -32099 | Server error |
eth_getTransactionReceipt until it returns a non-null receipt, or subscribe to newHeads and pending transactions via eth_subscribe for real-time updates — well suited to OP Mainnet's ~2-second blocks.eth_getTransactionCount, and use an application-level queue so you submit them in order rather than racing concurrent sends.eth_blockNumber, listen to newHeads through eth_subscribe to detect new tips, and confirm a block is still canonical with eth_getBlockByNumber before treating a transaction as final.net_version.10 (hex 0xa), which you can verify at any time with eth_chainId.eth_blockNumber call, and monitor latency and throughput before moving to OP Mainnet in production.