Optimism
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Optimism
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_getLogs returns every event log on OP Mainnet that matches a filter object — by block range (fromBlock/toBlock), contract address, indexed topics, or a single blockHash. It is the primary method for one-shot log queries and backfill indexing, the workhorse behind subgraphs and analytics pipelines tracking Superchain protocols like Velodrome and Synthetix. OP Mainnet is an OP Stack optimistic rollup (Bedrock) that settles to Ethereum L1 and charges gas in ETH; its ~2s blocks mean a given calendar window holds many blocks of logs. Send queries to https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa).
Transfer events for a token over a historical OP Mainnet block range to seed a balances index.blockHash and topics.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 1 | filter | object | نعم | Filter object. Fields: `fromBlock` (string, default "latest"), `toBlock` (string, default "latest"), `address` (string | string[]), `topics` ((string | string[] | null)[]), `blockHash` (string — mutually exclusive with fromBlock/toBlock). |
| النوع | الوصف |
|---|---|
| array | Array of log objects. Each log: `address`, `blockHash`, `blockNumber`, `data`, `logIndex`, `removed` (bool — true on reorg), `topics`, `transactionHash`, `transactionIndex`. |
Try it live in the Optimism playground.
| الكود | الرسالة | السبب |
|---|---|---|
-32005 | query exceeds max block range | The fromBlock–toBlock window exceeds the provider's block-range cap. |
-32005 | query returned more than 10000 results | Too many matching logs; narrow the filter or paginate. |
-32602 | invalid argument | blockHash combined with fromBlock/toBlock, or malformed topic format. |
removed field and re-query once the block has finalized on L1 before trusting the data.address/topics can trip provider timeouts or block-range caps; paginate in chunks of roughly 1,000–5,000 blocks, which on ~2s blocks still covers a useful span per call.eth_getLogs with fromBlock: "latest" in a tight loop wastes CUs — use eth_newFilter plus eth_getFilterChanges, or an eth_subscribe log subscription, for live tailing.المعاملات
Filter object. Fields: `fromBlock` (string, default "latest"), `toBlock` (string, default "latest"), `address` (string | string[]), `topics` ((string | string[] | null)[]), `blockHash` (string — mutually exclusive with fromBlock/toBlock).