This project consists of a Hats Protocol indexing SDK built with Ponder and a consumer application that demonstrates how to consume the Hats Ponder SDK. The consumer package contains the environment variables for the RPC and also the Docker configuration. The hats-ponder-sdk package is where the indexing logic happens, which is exported and used in the consumer. The project uses a monorepo structure managed with pnpm workspaces.
hats-indexer/
├── packages/
│ ├── hats-ponder-sdk/ # Core indexing SDK for Hats Protocol
│ └── consumer/ # Example consumer application
- Node.js >= 18.14
- pnpm >= 8.0.0
- Docker and Docker Compose
-
Clone the repository:
git clone <repository-url> cd hats-indexer
-
Install dependencies:
pnpm install
To build the Hats Ponder SDK:
pnpm sdk:build
All of the Ponder configuration is managed in the hats-ponder-sdk
package. The core configuration is in the ponder.config.ts
. This exports the createConfig
which is then used in the consumer
package's ponder.config.ts
. This enables a modular approach where our Ponder indexing configuration can be imported into other existing Ponder applications.
The schema and API files follow the same pattern. This is still experimental and we're working out the rough edges, but initial tests have demonstrated that this works.
Ponder provides powerful multichain support functionality. Our SDK follows the patterns outlined for use in Ponder versions >0.10.x
. There were significant changes to Ponder's internal API outlined in the Ponder Migration Guide.
While testing and developing, the start blocks are set to be rather recent. This is managed in the ponder.config.ts
within the hats-ponder-sdk
package. The startBlock
can be set for each contract/chain independently.
Ponder >0.10 relies on the onChainTable
function for the core indexing. Since we're still actively developing and testing, the indexing logic focuses primarily on the hat
table creation.
The consumer application can be run using Docker Compose for a consistent environment:
-
Set up environment variables:
# Copy the example environment file cp packages/consumer/env.example packages/consumer/.env # Edit the .env file with your specific values: # Add your RPC URLs: # - For Sepolia: Use an RPC provider like Infura, Alchemy, or your own node # - For Base Sepolia: Use Base's public RPC or your preferred provider
-
Start the services:
# If running from the root directory: docker-compose -f packages/consumer/docker/docker-compose.yml up -d # If running in the `docker` directory: cd packages/consumer/docker docker-compose up -d
To run the consumer in development mode:
pnpm consumer:dev
- The SDK (
packages/hats-ponder-sdk
) provides the core indexing functionality for the Hats Protocol - The consumer (
packages/consumer
) demonstrates how to use the SDK in a real application
pnpm sdk:build
: Build the SDKpnpm consumer:dev
: Run the consumer in development mode