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.

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

Connect to your ENSDb instance:

Terminal window
psql postgresql://user:password@host:5432/ensdb_devnet

Discover the available ENSDb Writer Schemas:

SQL
SELECT DISTINCT ens_indexer_schema_name
FROM ensnode.metadata;
Output
# ens_indexer_schema_name
1 ensindexer_0
2 ensindexer_1

Here are some example queries to get you started. Each example is available in raw SQL and with the ensdb-sdk for TypeScript projects.

See each example’s page for details on the query and how to run it against your ENSDb instance.