This project provides a REST and GraphQL API built with Elysia and Bun, designed to automate the indexing of smart contract events deployed by Catapulta users. It uses Rindexer for indexing and PostgreSQL as the database.
- Automatic indexing of events from deployed contracts
- Query events by contract and event type
- Sorting support for event data
- Proxy to Rindexer's GraphQL service
- Add new contracts and dynamically restart the indexer
- Swagger documentation available at
/docs
- Backend: Bun + Elysia + Swagger
- Indexer: Rindexer
- Database: PostgreSQL
- Containers: Docker + DevContainers
- Docker and Docker Compose
- VSCode with the Dev Containers extension
Important: create a
.env
file in the root directory with the necessary PostgreSQL and app variables:
POSTGRES_HOST=localhost
POSTGRES_PORT=5440
POSTGRES_USER=postgres
POSTGRES_PASSWORD=yourpassword
POSTGRES_DB=postgres
# Keys to interact with each network
INFURA_API_KEY=your_infura_key
...
git clone https://github.com/catapulta-sh/catapulta-auto-indexer.git
cd catapulta-auto-indexer
Select "Reopen in Container" when prompted by VSCode.
docker compose up --build
This will launch:
postgresql
on port5440
app
with Bun and Elysia on ports3000
(REST) and3001
(GraphQL)
Method | Path | Description |
---|---|---|
GET | /event-list |
Lists all event types indexed for a specific contract using composite key (contract_name + report_id) |
GET | /events |
Returns all events for a contract and specific event name, ordered by block number |
POST | /graphql |
Proxy to Rindexer's GraphQL service |
POST | /add-contracts |
Adds contracts to rindexer.yaml and restarts the indexer |
GET | / |
Basic test route (Hello Elysia) |
- Available at:
http://localhost:3000/docs
GET /event-list?contract_name=MyContract&report_id=abc123
Response:
{
"events": ["Transfer", "Approval", "Mint"],
"indexer_id": "internal_id_123"
}
GET /events?indexer_id=internal_id_123&event_name=Transfer&sort_order=-1
Response:
{
"events": [
{
"block_number": 18500000,
"log_index": 25,
"transaction_hash": "0xabc123...",
"from": "0x123...",
"to": "0x456...",
"value": "1000000000000000000"
}
]
}
{
"query": "query { allTransfers(first: 5) { nodes { txHash value } } }"
}
{
"contracts": [
{
"name": "MyContract",
"report_id": "abc123",
"network": "ethereum",
"address": "0xABC123...",
"start_block": "20000000",
"abi": [/* ABI JSON */]
}
]
}
├── .devcontainer
│ └── devcontainer.json
│ └── docker-compose-dev.yml
├── abis/
├── node_modules/
├── src/
│ └── index.ts
├── bun.lock
├── rindexer.yaml
├── Dockerfile
├── docker-compose.yml
├── package.json
├── tsconfig.json
├── .env
└── README.md
- Open
http://localhost:3000/docs
to test endpoints with Swagger UI. - Use tools like Postman or
curl
for manual testing. - The
rindexer
process restarts automatically whenever a new contract is added.
MIT © Catapulta Labs