Skip to content

Unigraph SQL Examples

These examples show the same queries two ways: in raw SQL (any PostgreSQL client, any language) and with the typed @ensnode/ensdb-sdk for TypeScript projects.

SQL access requires connecting to your own self-hosted ENSDb instance.

The Unigraph lives in ENSDb, a PostgreSQL database. Each ENSIndexer instance writes to its own ENSIndexer Schema (e.g. ensindexer_0); shared operational metadata lives in the ensnode schema.

Terminal window
# Production environment (mainnet data)
psql postgresql://user:password@host:5432/ensdb_mainnet
# Pre-production environment (testnet data)
psql postgresql://user:password@host:5432/ensdb_testnet
# Staging / local development environment
psql postgresql://user:password@host:5432/ensdb_devnet

Discover the available ENSIndexer Schemas:

SELECT DISTINCT ens_indexer_schema_name
FROM ensnode.metadata;