A Ponder indexer for Ethereum Attestation Service (EAS) attestations on Optimism.
This indexer tracks EAS attestations and stores them into Postgres database. It watches for Attested
and Revoked
events from the EAS contract on Optimism, decodes the attestation data according to predefined schemas, and stores the results in structured tables.
-
Schema Configuration
- Schemas are defined in
schemas.config.ts
with their IDs and optional attester addresses - Schema parameter signatures are defined in
src/schemas.ts
for decoding attestation data - Database tables are defined in
ponder.schema.ts
matching the schema structures
- Schemas are defined in
-
Event Processing
- Listens for
Attested
events matching configured schema IDs - Validates attester address if specified in schema config
- Retrieves full attestation data using
getAttestation
- Decodes raw data using schema-specific parameter signatures
- Stores decoded data in corresponding database tables
- Tracks revocations through
Revoked
events
- Listens for
-
Database Structure
- Each schema has its own table with appropriate columns
- All attestations store:
- Unique ID
- Recipient address
- Schema-specific data fields
- Revocation status
-
Install dependencies:
yarn install
-
Configure environment:
- Copy
.env.example
to.env
- Add your RPC URL for Optimism mainnet
- Copy
-
Start the indexer:
yarn dev
-
Add schema configuration in
schemas.config.ts
:export const schemas = [ { id: "0x...", name: "citizen", attester: "0x...", // optional }, ];
-
Define schema parameters in
src/schemas.ts
-
Add corresponding table definition in
ponder.schema.ts
-
Add schema to
ponder.config.ts
-
Update
src/index.ts
to include the new schema
- Add entity configuration in
ponder.schema.ts
- Add entity to
ponder.config.ts
- Update
src/index.ts
to include the new entity
The indexer exposes REST API endpoints for querying attestation data. Endpoints are automatically generated for each schema defined in schemas.config.ts
.
For each schema (citizen, badgeholder, gov_contribution, etc.), the following endpoint is available:
GET /api/{schema}/address/{address}
Example:
GET /api/citizen/address/0x1234...
Response:
{
"attestations": [
{
"id": "0xabcd...",
"recipient": "0x1234...",
"attester": "0x5678...",
"time": "2024-03-21T15:30:00Z",
"revoked": false
// schema-specific fields
}
]
}