IndexerModule
The IndexerModule provides efficient on-chain indexing of attestations by various parameters (subject, schema, attester, portal). It allows for quick retrieval of attestation IDs without relying solel
Link to the code
When to use this module?
Use this module when you need:
On-chain queryability of attestations by subject, schema, attester, or portal
Fast lookup of all attestations for a specific address or entity
To build on-chain logic that depends on finding related attestations
A backup indexing mechanism in case off-chain indexers are unavailable
The IndexerModule is particularly useful for smart contracts that need to query attestations on-chain, such as reputation systems or access control mechanisms.
When not to use this module?
Don't use this module if:
You only need off-chain querying (use the subgraph instead - it's more efficient and cost-effective)
You're creating many attestations and want to minimize gas costs (indexing adds gas overhead)
You need to track revoked attestations separately (this module doesn't un-index revoked attestations)
Important disclaimers
**This module has several limitations:**
Does not un-index revoked attestations - Revoked attestations remain in the index
Does not work as intended with bulk attestations - The attestation ID prediction may be incorrect during bulk operations
Does not consider chain prefix - The indexed attestation ID doesn't include the chain prefix used by the registry
How to use this module?
1. Include the module when registering your portal
Add the IndexerModule address to your portal's modules array. The module will automatically index attestations as they are created.
2. Query attestations
The IndexerModule provides several public view functions to retrieve attestation IDs:
Get attestations by subject
Returns all attestation IDs for a given subject.
Get attestations by subject and schema
Returns all attestation IDs for a specific subject and schema combination.
Get attestations by attester
Returns all attestation IDs created by a specific attester.
Get attestations by schema
Returns all attestation IDs using a specific schema.
Get attestations by portal
Returns all attestation IDs created through a specific portal.
Get attestations by portal and subject
Returns all attestation IDs for a specific portal and subject combination.
3. Manually index existing attestations
If you want to index attestations that were created before the module was added, you can use:
These functions allow anyone to index existing attestations by providing their IDs.
How to check if an attestation is indexed?
Returns true if the attestation has been indexed, false otherwise.
Gas considerations
Last updated