Polygonscan Event Log Filters by Address and Topic
Polygonscan event logs can be filtered through Etherscan API V2 by contract address, event topics and a selected range of Polygon PoS blocks. Set chainid=137 for mainnet, then use module=logs and action=getLogs with an Etherscan API key. The address selects the emitter; topics narrow matches by event signature or indexed parameter.
A wallet address inside a token event plays a different role from the contract that emitted it. Keeping those roles separate makes log searches useful for transfer analysis, application monitoring and reconciliation without confusing participants with emitters.
Contract Addresses Separate Emitters From Participants
The
address
filter scopes a query to a deployed contract on the selected network.
A log’s address identifies its emitting contract.
Sender and recipient addresses can appear among that event’s
indexed parameters
or non-indexed data. Their location follows the event declaration. A transaction that calls several contracts may contain logs with different emitting addresses, so its destination does not describe every log. Address-only searches retain the emitter’s different event types, which helps when the event of interest has not yet been identified.
Polygon PoS testnet requests use
chainid=80002
; those records belong to a different network from mainnet records queried with
chainid=137
.
Event Definitions Fix Topic Positions
Event Signatures
A contract’s application binary interface (ABI) lists its events, parameter types and indexing.
For a non-anonymous Solidity event,
topic0
contains the Keccak-256 hash of its canonical event signature.
The signature includes the event name and canonical parameter types in their declared order. Argument names and the
indexed
keyword are excluded. The event signature hash occupies 32 bytes; a function selector uses the first four bytes of its own signature hash. Anonymous events omit the signature topic, so
topic0
then holds an indexed argument when one exists. Non-anonymous events can have up to three indexed parameters; anonymous events can have four.
Indexed Parameter Order
Indexed parameters occupy topic slots in their declared order. Non-indexed parameters go into
data
. Topic conditions cannot inspect those values; value-based filtering of non-indexed fields requires decoding the retrieved data.
Address Encoding
An indexed
address
uses a 32-byte topic value, with leading zero padding. A plain wallet address and its encoded topic are different representations. The event’s declared field position distinguishes an indexed sender from an indexed recipient.
Hashed Parameter Values
Indexed
string
and
bytes
values use Keccak-256 hashes of their contents. Arrays and structs follow the ABI’s special encoding rules before hashing. A hash can match a known input. An ABI decoder cannot recover the original value from that topic alone. A separate non-indexed copy remains readable when the event includes one.
Filter Combinations Balance Coverage and Specificity
Etherscan API V2 supports address-only, topic-only and combined log queries over a block range. These configurations answer different questions: the emitter identifies where a record originated, while topic positions specify which indexed values qualify. This comparison uses non-anonymous events wherever
topic0
represents an event signature. Every configuration retains the request’s chain and block boundaries.
| Filter Configuration | Emitter Scope | Topic Requirement | Remaining Limit |
|---|---|---|---|
address
only
|
Selected contract | No topic condition | Different event types can match |
topic0
only
|
Any matching emitter |
Signature hash in
topic0
|
Contract identity remains unrestricted |
topic1
only
|
Any matching emitter |
Value in
topic1
|
Field meaning varies by event |
address
plus
topic0
|
Selected contract | Selected signature hash | Indexed participants remain unrestricted |
address
plus
topic0
AND
topic1
|
Selected contract | Both positions match | Non-indexed data remains unfiltered |
address
plus
topic0
OR
topic1
|
Selected contract | Either position matches | Other event signatures can qualify |
The
topic0_1_opr
parameter selects
and
or
or
between those positions. OR broadens the topic condition; it does not move a value between slots. Topic-only queries expose
topic0
through
topic3
, with pair operators such as
topic1_2_opr
. Each pair operator applies only when both corresponding topics are supplied.
Block Ranges and Pagination Define Export Coverage
Block boundaries define which part of Polygon PoS history a query covers, while pagination determines how many matching records appear in each response. The
fromBlock
and
toBlock
parameters name the starting and ending blocks. Keeping these bounds fixed makes page continuation easier to reconcile. The
offset
parameter controls records per page;
page
selects subsequent records. A response that fills a requested page can leave further matching logs outside that page. Its final row does not establish the end of the matching records within that block range.
Large queries can time out even when their filters are valid. Smaller block ranges reduce the dataset that each request must search. API rate limits remain a separate constraint that depends on the selected plan.
Retain the filter parameters and completed block ranges with exported records, so later imports can identify their actual coverage.
Response Fields Distinguish Empty Searches From Errors
Check the API response’s
status
,
message
and
result
fields to distinguish a valid empty result from an error.
A
status
value of
0
can indicate either an error or a valid search with no records.
Invalid credentials, unsupported chain selection and rate limiting require different corrections from a genuine no-match result. A timeout also leaves coverage unresolved. An unsuccessful request cannot establish that a contract emitted no matching events within the requested block range.
A valid empty result describes that particular filter and block range. It says nothing about events outside those conditions.
Event Decoding Determines the Meaning of a Match
Decoding a matching log gives its raw values the types and field meanings that the event declaration specifies. Contract verification can make that interface available beside published source code. Amount fields require their documented units. For ERC-20 amounts, human-readable scaling uses that token’s decimal precision when the token defines it. Historical token approval events describe recorded changes, while current permissions come from the relevant contract state. A matching signature alone establishes neither a token’s authenticity nor the authority of its emitter.
Everyday questions about Polygonscan
-
Do I Need a Wallet Connection to Query Event Logs?
- Event log queries through Etherscan API V2 require an API key, without a wallet connection or transaction signature. Reading indexed records does not submit an onchain transaction or incur network gas. API access remains subject to the selected plan’s chain coverage and usage limits, which are separate from transaction fees.
-
Can a V2 Log Query Return a Pending Transaction’s Events?
- The documented Etherscan API V2 block-range search retrieves event records from included transactions. Pending transactions do not yet have transaction receipts. An existing transaction hash therefore does not establish that a matching log exists in a searched block. Inclusion and the receipt provide the relevant execution context.
-
Why Can the Same Transfer Signature Match Different Token Standards?
- ERC-20 and ERC-721 Transfer events share the canonical signature Transfer(address,address,uint256). Their indexed layouts differ: ERC-20 places the amount in data, while ERC-721 indexes the token identifier. The indexed keyword does not change the signature hash. The emitting contract and event layout distinguish the amount from an NFT identifier.
-
Does an Event Log Search Include Every Internal Contract Call?
- Event log searches return emitted event records, not a complete trace of internal contract calls. Contract execution can involve calls that emit no matching event. A log therefore identifies a recorded emission within execution; it does not enumerate every operation that produced it. Use a complete execution trace to inspect internal calls. Etherscan’s internal transaction query by transaction hash returns only records with non-zero value.
-
Is a Transaction Hash Enough to Deduplicate Exported Events?
- A transaction hash alone cannot distinguish all events because a transaction can produce multiple logs. Preserve the network, block hash and log index to identify a particular included log, with its transaction hash retained for context. The log index describes its position within the block, so identical event contents can still represent distinct records.
-
What Does an Empty Data Field Mean in a Returned Log?
- An empty data field can be valid when an event has no non-indexed parameters. Its information can reside entirely in topics. That differs from an empty query result, which contains no matching log entries. The event declaration determines whether empty data fits the expected layout; it does not automatically indicate a decoding failure.
-
Will an Old Polygonscan API Key Work With V2 Log Queries?
- Etherscan API V2 requires an Etherscan API key; legacy Polygonscan keys are not valid V2 credentials. Selecting the correct Polygon PoS chain ID does not convert an old key into a valid one. An authentication error concerns API access and cannot establish whether the requested contract events exist.