Permissions By User
Resources and roles for an address in the permissions graph. Terminal window Terminal window
Run in ENSAdmin
Open an interactive playground to execute this example on our sepolia-v2
ENSNode instance.
GraphQL
query PermissionsByUser($address: Address!) { account(by: { address: $address }) { permissions { edges { node { resource roles } } } }}Payload and transport examples
{ "address": "0x205d2686da3bf33f64c17f21462c51b5ead462cf"}
Response is an illustrative snapshot; live data depends on your ENSNode instance. The curl tab
shows a POST to
https://api.v2-sepolia.ensnode.io/api/omnigraph
Open an interactive playground to execute this example on our sepolia-v2
ENSNode instance.
TypeScript
import { createEnsNodeClient } from "enssdk/core";import { graphql, omnigraph } from "enssdk/omnigraph";
const client = createEnsNodeClient({ url: process.env.ENSNODE_URL || "https://api.v2-sepolia.ensnode.io"}).extend(omnigraph);
const PermissionsByUserQuery = graphql(` query PermissionsByUser($address: Address!) { account(by: { address: $address }) { permissions { edges { node { resource roles } } } } }`);
const result = await client.omnigraph.query({ query: PermissionsByUserQuery, variables: { address: "0x205d2686da3bf33f64c17f21462c51b5ead462cf", },});
if (result.errors) throw new Error(JSON.stringify(result.errors));console.log(JSON.stringify(result.data, null, 2));enssdk setup and output
# 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.13.1 && npm install -D tsx typescript @types/node# 3. Paste the TypeScript snippet above into src/index.ts# 4. RunENSNODE_URL=https://api.v2-sepolia.ensnode.io npm startOutput matches the GraphQL Response snapshot; live output depends on your ENSNode instance. See the enssdk docs for gql.tada plugin and tsconfig setup.
Open an interactive playground to execute this example on our sepolia-v2
ENSNode instance.
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.v2-sepolia.ensnode.io"}).extend(omnigraph);
const PermissionsByUserQuery = graphql(` query PermissionsByUser($address: Address!) { account(by: { address: $address }) { permissions { edges { node { resource roles } } } } }`);
function PermissionsByUserResult() { const [result] = useOmnigraphQuery({ query: PermissionsByUserQuery, variables: { address: "0x205d2686da3bf33f64c17f21462c51b5ead462cf", }, }); 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}> <PermissionsByUserResult /> </OmnigraphProvider> );}enskit setup and output
# 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.13.1 enssdk@1.13.1# 3. Copy the TSX snippet above into src/App.tsx# 4. RunVITE_ENSNODE_URL=https://api.v2-sepolia.ensnode.io npm run devOutput matches the GraphQL Response snapshot; live output depends on your ENSNode instance. See the enskit docs for gql.tada plugin and provider setup.
Back to Examples