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 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