Account Primary Name
Load a primary name for an account on Ethereum, including profile information. Terminal window Terminal window Terminal window
Run in ENSAdmin
Open an interactive playground to execute this example on our alpha
ENSNode instance.
GraphQL
query AccountPrimaryName($address: Address!) { account(by: { address: $address }) { address resolve { primaryName(by: { chainName: ETHEREUM }) { name { interpreted beautified } resolve { profile { description socials { twitter { httpUrl } } } } } } }} Variables
{ "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"} Output
{ "data": { "account": { "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "resolve": { "primaryName": { "name": { "interpreted": "vitalik.eth", "beautified": "vitalik.eth" }, "resolve": { "profile": { "description": "mi pinxe lo crino tcati", "socials": { "twitter": { "httpUrl": "https://x.com/VitalikButerin" } } } } } } } }}Output matches a GraphQL Response from alpha ; live output depends on your ENSNode instance.
Opens an editable StackBlitz project with this snippet.
TypeScript
import { createEnsNodeClient } from "enssdk/core";import { graphql, omnigraph } from "enssdk/omnigraph";
const client = createEnsNodeClient({ url: process.env.ENSNODE_URL || "https://api.alpha.ensnode.io"}).extend(omnigraph);
const AccountPrimaryNameQuery = graphql(` query AccountPrimaryName($address: Address!) { account(by: { address: $address }) { address resolve { primaryName(by: { chainName: ETHEREUM }) { name { interpreted beautified } resolve { profile { description socials { twitter { httpUrl } } } } } } } }`);
const result = await client.omnigraph.query({ query: AccountPrimaryNameQuery, variables: { address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", },});
if (result.errors) throw new Error(JSON.stringify(result.errors));console.log(JSON.stringify(result.data, null, 2)); Output
{ "data": { "account": { "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "resolve": { "primaryName": { "name": { "interpreted": "vitalik.eth", "beautified": "vitalik.eth" }, "resolve": { "profile": { "description": "mi pinxe lo crino tcati", "socials": { "twitter": { "httpUrl": "https://x.com/VitalikButerin" } } } } } } } }}Output matches a GraphQL Response from alpha ; live output depends on your ENSNode instance.
enssdk package manager setup
# 1. Create projectmkdir -p my-ens-script/src && cd my-ens-scriptnpm init -y && touch src/index.tsnpm pkg set type=module scripts.start="tsx src/index.ts"# 2. Install dependenciesnpm install enssdk@1.15.1 && npm install -D tsx typescript @types/node# 3. Paste the TypeScript snippet above into src/index.ts# 4. RunENSNODE_URL=https://api.alpha.ensnode.io npm startSee the enssdk docs for gql.tada plugin and tsconfig setup.
Opens an editable StackBlitz project with this snippet.
TSX (React)
import { OmnigraphProvider, useOmnigraphQuery, graphql } from "enskit/react/omnigraph";import { createEnsNodeClient } from "enssdk/core";import { omnigraph } from "enssdk/omnigraph";
const client = createEnsNodeClient({ url: import.meta.env.VITE_ENSNODE_URL || "https://api.alpha.ensnode.io"}).extend(omnigraph);
const AccountPrimaryNameQuery = graphql(` query AccountPrimaryName($address: Address!) { account(by: { address: $address }) { address resolve { primaryName(by: { chainName: ETHEREUM }) { name { interpreted beautified } resolve { profile { description socials { twitter { httpUrl } } } } } } } }`);
function AccountPrimaryNameResult() { const [result] = useOmnigraphQuery({ query: AccountPrimaryNameQuery, variables: { address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", }, }); const { data, fetching, error } = result; if (!data && fetching) return <p>Loading…</p>; if (error) return <p>Error: {error.message}</p>; if (!data) return <p>No data returned.</p>; const formatted = JSON.stringify( data, (_, value) => (typeof value === "bigint" ? value.toString() : value), 2, ); return <code>{formatted}</code>;}
export default function App() { return ( <OmnigraphProvider client={client}> <AccountPrimaryNameResult /> </OmnigraphProvider> );} Output
{ "data": { "account": { "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "resolve": { "primaryName": { "name": { "interpreted": "vitalik.eth", "beautified": "vitalik.eth" }, "resolve": { "profile": { "description": "mi pinxe lo crino tcati", "socials": { "twitter": { "httpUrl": "https://x.com/VitalikButerin" } } } } } } } }}Output matches a GraphQL Response from alpha ; live output depends on your ENSNode instance.
enskit package manager setup
# 1. Create projectnpm create vite@latest my-ens-app -- --template react-ts --no-interactive --no-immediatecd my-ens-app# 2. Install dependenciesnpm installnpm install enskit@1.15.1 enssdk@1.15.1# 3. Copy the TSX snippet above into src/App.tsx# 4. RunVITE_ENSNODE_URL=https://api.alpha.ensnode.io npm run devSee the enskit docs for gql.tada plugin and provider setup.
cURL
# POST JSON to your ENSNode Omnigraph endpoint (same path enssdk uses).curl -sS -X POST "https://api.alpha.ensnode.io/api/omnigraph" \ -H "Content-Type: application/json" \ -d '{ "query": "query AccountPrimaryName($address: Address!) { account(by: { address: $address }) { address resolve { primaryName(by: { chainName: ETHEREUM }) { name { interpreted beautified } resolve { profile { description socials { twitter { httpUrl } } } } } } } }", "variables": {"address":"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"}}' Response
{ "data": { "account": { "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "resolve": { "primaryName": { "name": { "interpreted": "vitalik.eth", "beautified": "vitalik.eth" }, "resolve": { "profile": { "description": "mi pinxe lo crino tcati", "socials": { "twitter": { "httpUrl": "https://x.com/VitalikButerin" } } } } } } } }}Output matches a GraphQL Response from alpha ; live output depends on your ENSNode instance.
Back to Examples