Account Domains
Performing SQL queries on the ENS Unigraph requires that you have the unigraph plugin activated in your ENSNode instance. Learn more
Count the Domains owned by an address, grouped by Domain type (ENSv1Domain vs ENSv2Domain) — a single query spanning both protocol versions. See Connect for setup.
An ENSIndexer Schema is a
database schema within an ENSDb instance, used to store indexed ENS data from a given ENSIndexer instance. We use ensindexer_0 as the ENSIndexer Schema Name in examples on this page, but your ENSIndexer instance may be configured to use a different schema name based on how you configured its `ENSINDEXER_SCHEMA_NAME`
environment variable. Make sure to replace ensindexer_0 with the actual schema
name used by your ENSIndexer instance when querying the ENSDb instance directly.
SELECT type, count(*) FROM ensindexer_0.domainsWHERE owner_id = '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'GROUP BY type;View Query Result
[
{
"type": "ENSv1Domain",
"count": 2
},
{
"type": "ENSv2Domain",
"count": 14
}
] ensDb query builder and ensIndexerSchema
schema definition in the Connect section if you haven't
already.
import { count, eq } from "drizzle-orm";
const counts = await ensDb .select({ type: ensIndexerSchema.domain.type, count: count() }) .from(ensIndexerSchema.domain) .where(eq(ensIndexerSchema.domain.ownerId, "0x70997970c51812dc3a010c7d01b50e0d17dc79c8")) .groupBy(ensIndexerSchema.domain.type);View Query Result
[
{
"type": "ENSv1Domain",
"count": 2
},
{
"type": "ENSv2Domain",
"count": 14
}
]