yarn
yarn buildSee https://github.com/threefoldtech/tfchain
Both compose stacks use a shared external network. Create it once:
docker network create tfgrid_bkndCheck indexer/.env and adjust the websocket endpoint to your local TFChain address.
cd indexer
docker compose up -dIndexer services should now be started. Check if it's syncing properly by streaming the ingest logs:
docker logs indexer-ingest-1 -fYou should see TFChain blocks being processed:
Check .env and adjust the settings. When running the processor locally (not in Docker) while the indexer runs in Docker, change INDEXER_ENDPOINT_URL to use the published port:
# .env — for local development (processor outside Docker):
INDEXER_ENDPOINT_URL=http://localhost:8888/graphql
# .env — for Docker deployment (processor inside Docker, shared network):
# INDEXER_ENDPOINT_URL=http://gateway:8000/graphqlStart the local PostgreSQL container and run the processor:
yarn build
yarn db:up
yarn processYou should see TFChain blocks being processed by the processor:
If you make changes, stop the containers before restarting:
docker compose downAt this step, running docker ps should show the indexer containers running:
Start the query node:
yarn apiNow you can use the GraphQL playground at http://localhost:4000/graphql
When TFChain has a new spec version with type changes, see typeChanges.md for the full workflow. The short version:
# Point at your local chain (or a remote network via WS_URL=wss://...)
make typegen-add
# Check what changed in src/types/, add handler branches if needed
yarn buildIf you need to add new entities or fields to the GraphQL API:
- Edit
schema.graphql - Regenerate models and create a migration:
yarn codegen yarn build yarn db:create-migration
- Add or update event handlers in
src/mappings/ - Register new events in
src/processor.tsif needed - Test locally:
yarn db:up yarn db:migrate yarn process
The simplest and safest approach. Wipes the entire PostgreSQL data directory:
# Stop processor and DB
docker compose down processor db
# Wipe postgres data
rm -rf /path/to/postgres-data/*
# Restart - processor will run migrations and start from block 0
docker compose up -d./scripts/reset-db.sh
yarn processUse SQD_DEBUG=sqd:processor:mapping for event processing visibility. Avoid sqd:processor:* which floods logs with serialization errors from a known node-fetch bug.
# In .env or docker-compose.yml environment:
SQD_DEBUG=sqd:processor:mapping# Current height
docker exec db-container psql -U postgres -d tfgrid-graphql \
-c 'SELECT height FROM squid_processor.status;'
# Entity counts
docker exec db-container psql -U postgres -d tfgrid-graphql -c "
SELECT 'farms' AS entity, count(*) FROM farm
UNION ALL SELECT 'nodes', count(*) FROM node
UNION ALL SELECT 'twins', count(*) FROM twin
UNION ALL SELECT 'contracts', count(*) FROM node_contract;
"

