### Install ENSjs and viem Source: https://github.com/ensdomains/ensjs/blob/main/README.md Install the ENSjs library and viem using npm. viem is a dependency for ENSjs. ```sh npm install @ensdomains/ensjs viem ``` -------------------------------- ### Start Test Environment with ENS Contracts Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Starts a local test environment with ENS contracts deployed. Useful for development and testing. ```bash pnpm tenv start ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Installs project dependencies using pnpm. Ensure pnpm is installed globally. ```bash pnpm install ``` -------------------------------- ### Install @ensdomains/ensjs-react Source: https://github.com/ensdomains/ensjs/blob/main/packages/react/README.md Install the @ensdomains/ensjs-react package after installing wagmi. This command uses pnpm for package management. ```sh pnpm install @ensdomains/ensjs-react ``` -------------------------------- ### Start Development Environment with Extra Time Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Starts a development environment, potentially with extended timeouts for operations. ```bash pnpm denv ``` -------------------------------- ### Get Supported Interfaces with ensjs Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getSupportedInterfaces.md Use this snippet to get the supported interfaces for a given contract address. Ensure you have viem and ensjs installed and imported correctly. The function returns a promise that resolves to an array of booleans indicating support for each queried interface. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getSupportedInterfaces } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getSupportedInterfaces(client, { address: '0x58774Bb8acD458A640aF0B88238369A167546ef2', interfaces: ['0x2f435428', '0x23b872dd'], }) // [true, false] ``` -------------------------------- ### Create ENS Subgraph Client with Viem Source: https://github.com/ensdomains/ensjs/blob/main/docs/basics/extending-the-viem-client.md Extend a Viem client with `ensSubgraphActions` to query ENS subgraph records. Ensure `@ensdomains/ensjs` is installed. ```typescript import { http, createClient } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const client = createClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) const subgraphRecords = await client.getSubgraphRecords({ name: 'ens.eth' }) ``` -------------------------------- ### Initialize Viem Client with ENS Contracts Source: https://github.com/ensdomains/ensjs/blob/main/docs/basics/using-the-viem-client.md Wrap your viem chain with `addEnsContracts` to include ENS contract addresses. This setup is necessary before using ENSjs public methods with the viem client. ```typescript import { http, createClient } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getAddressRecord } from '@ensdomains/ensjs/public' const client = createClient({ chain: addEnsContracts(mainnet), transport: http(), }) const ethAddress = getAddressRecord(client, { name: 'ens.eth' }) ``` -------------------------------- ### Start Anvil Without ENS Node Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Launches the Anvil local Ethereum node without the ENS node, useful for specific testing scenarios. ```bash pnpm anvil ``` -------------------------------- ### getAbiRecord Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Gets the ABI record for a name. ```APIDOC ### getAbiRecord **getAbiRecord**: (`parameters`) => `Promise`< `GetAbiRecordReturnType` > Gets the ABI record for a name #### Parameters - `parameters` ({ name: string; }) - Required - GetAbiRecordParameters #### Returns `Promise`< `GetAbiRecordReturnType` > ABI record for the name, or `null` if not found. GetAbiRecordReturnType #### Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getAbiRecord({ name: 'ens.eth' }) // TODO: real example ``` ``` -------------------------------- ### getAvailable Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Gets the availability of a name to register. ```APIDOC ### getAvailable **getAvailable**: (`parameters`) => `Promise`< `boolean` > Gets the availability of a name to register #### Parameters - `parameters` ({ name: string; }) - Required - #### Returns `Promise`< `boolean` > #### Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getAvailable({ name: 'ens.eth' }) // false ``` ``` -------------------------------- ### getAddressRecord Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Gets an address record for a name and specified coin. ```APIDOC ### getAddressRecord **getAddressRecord**: (`parameters`) => `Promise`< `GetAddressRecordReturnType` > Gets an address record for a name and specified coin #### Parameters - `parameters` ({ name: string; coin?: string | number | undefined; bypassFormat?: boolean | undefined; }) - Required - GetAddressRecordParameters #### Returns `Promise`< `GetAddressRecordReturnType` > Coin value object, or `null` if not found. GetAddressRecordReturnType #### Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getAddressRecord({ name: 'ens.eth', coin: 'ETH' }) // { id: 60, name: 'ETH , value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7' } ``` ``` -------------------------------- ### Get ENS Wrapper Data with Viem Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Fetches wrapper data for an ENS name using Viem. Requires ensPublicActions extension. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getWrapperData({ name: 'ilikelasagna.eth' }) ``` -------------------------------- ### getContentHashRecord Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getContentHashRecord.md Gets the content hash record for a name. ```APIDOC ## getContentHashRecord() ### Description Gets the content hash record for a name. ### Method `getContentHashRecord(client, parameters)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getContentHashRecord } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getContentHashRecord(client, { name: 'ens.eth' }) // { protocolType: 'ipfs', decoded: 'k51qzi5uqu5djdczd6zw0grmo23j2vkj9uzvujencg15s5rlkq0ss4ivll8wqw' } ``` ### Response #### Success Response (200) `Promise` - Content hash object, or `null` if not found. #### Response Example ```json { "protocolType": "ipfs", "decoded": "k51qzi5uqu5djdczd6zw0grmo23j2vkj9uzvujencg15s5rlkq0ss4ivll8wqw" } ``` ``` -------------------------------- ### Fetch ENS Profile Records with Fallbacks Source: https://github.com/ensdomains/ensjs/blob/main/docs/basics/fetching-a-profile.md Fetches ENS profile records using subgraph data and provides fallback records for specific coin and text entries. Ensure ensjs and viem are installed. ```typescript import { http } from 'viem' import { mainnet } from 'viem/chains' import { createEnsPublicClient } from '@ensdomains/ensjs' const client = createEnsPublicClient({ chain: mainnet, transport: http(), }) const subgraphRecords = client.getSubgraphRecords({ name: 'ens.eth' }) const records = client.getRecords({ name: 'ens.eth', records: { coins: [...(subgraphRecords?.coins || []), 'BTC', 'ETH', 'ETC', 'SOL'], texts: [ ...(subgraphRecords?.texts || []), 'avatar', 'email', 'description', ], contentHash: true, abi: true, }, }) ``` -------------------------------- ### Get DNS Import Data with ensjs Source: https://github.com/ensdomains/ensjs/blob/main/docs/dns/function.getDnsImportData.md Use this snippet to fetch DNS import data for a given ENS name. Ensure you have a viem client configured with ENS contracts. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getDnsImportData } from '@ensdomains/ensjs/dns' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const data = await getDnsImportData(client, { name: 'example.eth', }) ``` -------------------------------- ### Get Primary ENS Name with getName() Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getName.md Use this snippet to fetch the primary ENS name for an address. Ensure your Viem client is set up with ENS contracts. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getName } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getName(client, { address: '0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5', }) // { name: 'nick.eth', match: true, reverseResolverAddress: '0xa2c122be93b0074270ebee7f6b7292c7deb45047', resolverAddress: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41' } ``` -------------------------------- ### Get Wrapper Data for ENS Name Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getWrapperData.md Use this snippet to fetch wrapper data for an ENS name. Ensure you have a viem client configured with ENS contracts. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getWrapperData } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getWrapperData(client, { name: 'ilikelasagna.eth' }) ``` -------------------------------- ### Get Text Record with ensjs Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getTextRecord.md Use this snippet to fetch a text record for a given ENS name and key. Ensure you have initialized the viem client with ENS contracts. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getTextRecord } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getTextRecord(client, { name: 'ens.eth', key: 'com.twitter', }) // ensdomains ``` -------------------------------- ### Get Address Record with getAddressRecord Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Fetches the address record for an ENS name and a specific coin type. The client must be extended with `ensPublicActions` and ENS contracts added to the chain. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getAddressRecord({ name: 'ens.eth', coin: 'ETH' }) // { id: 60, name: 'ETH , value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7' } ``` -------------------------------- ### Get Subgraph Records with Viem Client Source: https://github.com/ensdomains/ensjs/blob/main/docs/subgraph/function.getSubgraphRecords.md Use this snippet to fetch records for an ENS name from the subgraph. Ensure you have a Viem client configured, preferably with an API key for TheGraph to avoid rate limiting. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getSubgraphRecords } from '@ensdomains/ensjs/subgraph' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getSubgraphRecords(client, { name: 'ens.eth' }) // { // isMigrated: true, // createdAt: { date: 2019-08-26T05:09:01.000Z, value: 1566796141000 }, // texts: [ 'snapshot', 'url', 'avatar', 'com.twitter', 'com.github' ], // coins: [ '60' ] // } ``` -------------------------------- ### Get Wrapped ENS Name Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Use this to get the full name for a name with unknown labels from the NameWrapper. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getWrapperName({ name: '[4ca938ec1b323ca71c4fb47a712abb68cce1cabf39ea4d6789e42fbc1f95459b].eth', }) // wrapped.eth ``` -------------------------------- ### Get ENS Name Expiry Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Retrieves the expiry information for an ENS name. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getExpiry({ name: 'ens.eth' }) // { expiry: { date: Date, value: 1913933217n }, gracePeriod: 7776000, status: 'active' } ``` -------------------------------- ### Get Subgraph Registrant Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsSubgraphClient.md Retrieves the registrant address for a given ENS name from the subgraph. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) const result = await client.getSubgraphRegistrant({ name: 'ens.eth' }) // 0xb6E040C9ECAaE172a89bD561c5F73e1C48d28cd9 ``` -------------------------------- ### Get Subnames from Subgraph Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsSubgraphClient.md Fetches an array of subnames associated with a given ENS name from the subgraph. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) const result = await client.getSubnames({ name: 'ens.eth' }) ``` -------------------------------- ### Build the Project Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Compiles the project's code, generating build artifacts. This command is typically run before publishing or deploying. ```bash pnpm build ``` -------------------------------- ### Get Primary ENS Name for Address Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Fetches the primary ENS name associated with a given address. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getName({ address: '0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5', }) // { name: 'nick.eth', match: true, reverseResolverAddress: '0xa2c122be93b0074270ebee7f6b7292c7deb45047', resolverAddress: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41' } ``` -------------------------------- ### Get ENS Content Hash Record Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Retrieves the content hash record for a given ENS name. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getContentHashRecord({ name: 'ens.eth' }) // { protocolType: 'ipfs', decoded: 'k51qzi5uqu5djdczd6zw0grmo23j2vkj9uzvujencg15s5rlkq0ss4ivll8wqw' } ``` -------------------------------- ### Create ENS Public Client Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Use `createEnsPublicClient` to initialize a client for interacting with ENS. Requires Viem's `http` transport and a chain configuration. ```typescript import { http } from 'viem' import { mainnet } from 'viem/chains' import { createEnsPublicClient } from '@ensdomains/ensjs' const client = createEnsPublicClient({ chain: mainnet, transport: http(), }) ``` -------------------------------- ### Get Decoded ENS Name Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Fetches the full ENS name for a given name with unknown labels using the subgraph. Requires ensjs and viem setup. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) const result = await client.getDecodedName({ name: '[5cee339e13375638553bdf5a6e36ba80fb9f6a4f0783680884d92b558aa471da].eth', }) // ens.eth ``` -------------------------------- ### Get ENS Name History with ensjs Source: https://github.com/ensdomains/ensjs/blob/main/docs/subgraph/function.getNameHistory.md Use this snippet to retrieve the history of an ENS name from the subgraph. Ensure you have viem and ensjs installed. It's recommended to use an API key from TheGraph to avoid rate limiting. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getNameHistory } from '@ensdomains/ensjs/subgraph' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getNameHistory(client, { name: 'ens.eth' }) ``` -------------------------------- ### Create ENS Wallet Client Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Initializes an ENS wallet client for write operations. Requires chain, transport, and an account (signer). ```typescript createEnsWalletClient({ chain, transport, account }) ``` -------------------------------- ### Get Records for ENS Name with ENSJS Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Retrieves specified records (texts, coins, contentHash) for an ENS name. This example demonstrates fetching Twitter, GitHub, and ETH address records, along with the content hash. Requires ensPublicActions extension. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getRecords({ name: 'ens.eth', texts: ['com.twitter', 'com.github'], coins: ['ETH'], contentHash: true, }) // { texts: [{ key: 'com.twitter', value: 'ensdomains' }, { key: 'com.github', value: 'ensdomains' }], coins: [{ id: 60, name: 'ETH', value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7' }], contentHash: { protocolType: 'ipns', decoded: 'k51qzi5uqu5djdczd6zw0grmo23j2vkj9uzvujencg15s5rlkq0ss4ivll8wqw' } } ``` -------------------------------- ### Create Subname with Wallet Client Source: https://github.com/ensdomains/ensjs/blob/main/docs/wallet/function.createSubname.md Use this snippet to create a subname using a wallet client. Ensure you have imported the necessary functions from 'viem' and '@ensdomains/ensjs'. The wallet client needs to be configured with an ENS-compatible chain. ```typescript import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { createSubname } from '@ensdomains/ensjs/wallet' const wallet = createWalletClient({ chain: addEnsContracts(mainnet), transport: custom(window.ethereum), }) const hash = await createSubname(wallet, { name: 'sub.ens.eth', owner: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7', contract: 'registry', }) // 0x... ``` -------------------------------- ### Create ENS Wallet Client Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsWalletClient.md Use this function to create an ENS Wallet Client. It requires a viem Transport and Chain configuration. Ensure window.ethereum is available for browser-based wallets. ```typescript import { custom } from 'viem' import { mainnet } from 'viem/chains' import { createEnsWalletClient } from '@ensdomains/ensjs' const client = createEnsWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) ``` -------------------------------- ### Local Publishing for Testing Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Publishes packages locally for testing purposes. This allows you to test package interactions before a full release. ```bash pnpm publish:local:ensjs ``` ```bash pnpm publish:local:ens-test-env ``` -------------------------------- ### Run Linter with Biome Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Executes the Biome linter to check for code style and potential issues. This project uses Biome instead of ESLint. ```bash pnpm lint ``` -------------------------------- ### Run All Tests Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Executes all tests in the project without file parallelism. Ensure all tests pass before committing. ```bash pnpm test ``` -------------------------------- ### Get ENS Name Price Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getPrice.md Use this snippet to get the price of an ENS name for a specific duration. Ensure you have initialized the viem client with ENS contracts. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getPrice } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getPrice(client, { nameOrNames: 'ens.eth', duration: 31536000, }) // { base: 352828971668930335n, premium: 0n } ``` -------------------------------- ### Run Changeset Commands Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Executes changeset commands for managing package versions and changelogs. This is crucial for releasing new versions. ```bash pnpm chgset:run ``` ```bash pnpm chgset:version ``` ```bash pnpm chgset:version:prerelease ``` -------------------------------- ### Get Address Record - ensjs Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getAddressRecord.md Use this function to get an address record for a name and specified coin. Ensure your viem client is configured with ENS contracts. The default coin is 'ETH' (60). ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getAddressRecord } from '@ensdomains/ensjs/public' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getAddressRecord(client, { name: 'ens.eth', coin: 'ETH' }) // { id: 60, name: 'ETH , value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7' } ``` -------------------------------- ### Extend viem WalletClient with ENS actions Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.ensWalletActions.md Use this to add ENS wallet functionalities to your viem WalletClient. Ensure you import `addEnsContracts` and `ensWalletActions`, and configure your chain with ENS contracts. ```typescript import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensWalletActions } from '@ensdomains/ensjs' const clientWithEns = createWalletClient({ chain: addEnsContracts(mainnet), transport: custom(window.ethereum), }).extend(ensWalletActions) ``` -------------------------------- ### Create ENS Subgraph Client Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsSubgraphClient.md Use createEnsSubgraphClient to initialize a client for interacting with the ENS subgraph. Requires a viem Chain and Transport configuration. ```typescript import { http } from 'viem' import { mainnet } from 'viem/chains' import { createEnsSubgraphClient } from '@ensdomains/ensjs' const client = createEnsSubgraphClient({ chain: mainnet, transport: http(), }) ``` -------------------------------- ### Manage Versions with pnpm Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Uses pnpm's version management capabilities. This command is part of the package management workflow. ```bash pnpm ver ``` -------------------------------- ### Create ENS Public Client Source: https://github.com/ensdomains/ensjs/blob/main/README.md Create a public ENS client using viem transports and chains. This client provides read and subgraph functions. ```ts import { http } from 'viem' import { mainnet } from 'viem/chains' import { createEnsPublicClient } from '@ensdomains/ensjs' const client = createEnsPublicClient({ chain: mainnet, transport: http(), }) const ethAddress = client.getAddressRecord({ name: 'ens.eth' }) ``` -------------------------------- ### GetNamesForAddress API Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Gets the names associated with a given address from the subgraph. ```APIDOC ## GET /ensdomains/ensjs/getNamesForAddress ### Description Gets the names for an address from the subgraph. ### Method GET ### Endpoint /ensdomains/ensjs/getNamesForAddress ### Parameters #### Query Parameters - **parameters** (GetNamesForAddressParameters) - Required - GetNamesForAddressParameters ### Response #### Success Response (200) - **names** (array) - Name array. #### Response Example ```json { "names": [ "ens.eth", "resolver.eth" ] } ``` ``` -------------------------------- ### createEnsWalletClient Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsWalletClient.md Creates an ENS Wallet Client with a given Transport configured for a Chain. ```APIDOC ## Function: createEnsWalletClient() ### Description Creates an ENS Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html). ### Type Parameters | Parameter | Default | | :------------------------------------------------------------------------- | :---------- | | `TTransport` _extends_ `Transport` | - | | `TChain` _extends_ `Chain` | - | | `TAccountOrAddress` _extends_ `undefined` \| \`0x${string}\` \| `Account` | `undefined` | ### Parameters | Parameter | Type | Description | | :-------- | :----------------------------------------------------------------------- | :-------------------- | | `config` | `EnsWalletClientConfig`\< `TTransport`, `TChain`, `TAccountOrAddress` \> | EnsWalletClientConfig | ### Returns An ENS Wallet Client. EnsWalletClient ### Example ```ts import { custom } from 'viem' import { mainnet } from 'viem/chains' import { createEnsWalletClient } from '@ensdomains/ensjs' const client = createEnsWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) ``` ``` -------------------------------- ### GET /public/getExpiry Source: https://github.com/ensdomains/ensjs/blob/main/docs/public/function.getExpiry.md Retrieves the expiry date, grace period, and status for an ENS name. ```APIDOC ## GET /public/getExpiry ### Description Gets the expiry for a name. ### Method GET ### Endpoint /public/getExpiry ### Parameters #### Query Parameters - **name** (string) - Required - Name to get expiry for - **contract** (ContractOption) - Optional - Specific contract to use to get expiry ### Request Example ```json { "name": "ens.eth" } ``` ### Response #### Success Response (200) - **expiry** (object) - Expiry object, or null if no expiry. Contains `date` (Date) and `value` (BigInt). - **gracePeriod** (number) - The duration of the grace period in seconds. - **status** (string) - The status of the name's expiry ('active', 'gracePeriod', 'expired'). #### Response Example ```json { "expiry": { "date": "2027-04-21T00:00:00.000Z", "value": 1913933217n }, "gracePeriod": 7776000, "status": "active" } ``` ``` -------------------------------- ### Create ENS Public Client Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Initializes a read-only ENS public client. Requires chain and transport configuration. ```typescript createEnsPublicClient({ chain, transport }) ``` -------------------------------- ### Get DNS Owner Source: https://github.com/ensdomains/ensjs/blob/main/docs/dns/function.getDnsOwner.md Retrieves the DNS owner of a name by looking up its DNS records. ```APIDOC ## GET /dns/owner ### Description Gets the DNS owner of a name, via DNS record lookup. ### Method GET ### Endpoint /dns/owner ### Parameters #### Query Parameters - **name** (string) - Required - The name to look up the DNS owner for. ### Request Example ```json { "name": "ens.domains" } ``` ### Response #### Success Response (200) - **owner** (string) - The address of the DNS owner. #### Response Example ```json { "owner": "0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5" } ``` ``` -------------------------------- ### Extend viem client with ENS public actions Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.ensPublicActions.md Use this snippet to extend a viem public client with ENS functionality. Ensure the chain is configured with ENS contracts using `addEnsContracts`. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const clientWithEns = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) ``` -------------------------------- ### Batching Calls with Viem Client Source: https://github.com/ensdomains/ensjs/blob/main/docs/basics/batching-calls.md Utilize the standalone `batch` function from ENSjs with a Viem client to execute multiple ENS public method calls concurrently. The Viem client must be configured with ENS contracts using `addEnsContracts`. ```typescript import { http, createClient } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { batch, getAddressRecord, getTextRecord, } from '@ensdomains/ensjs/public' const client = createClient({ chain: addEnsContracts(mainnet), transport: http(), }) const [ethAddress, twitterUsername] = batch( client, getAddressRecord.batch({ name: 'ens.eth' }), getTextRecord.batch({ name: 'ens.eth', key: 'com.twitter' }), ) /* [ { id: 60, name: 'ETH', value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7' }, 'ensdomains' ] */ ``` -------------------------------- ### getNameHistory() Source: https://github.com/ensdomains/ensjs/blob/main/docs/subgraph/function.getNameHistory.md Gets the history of a name from the subgraph. It's recommended to use an API key from TheGraph to avoid rate limiting. ```APIDOC ## Function: getNameHistory() ### Description Gets the history of a name from the subgraph. ### Method POST ### Endpoint /ensdomains/ensjs/subgraph ### Parameters #### Request Body - **client** (ClientWithEns) - Required - The ENSJS client instance. - **parameters** (GetNameHistoryParameters) - Required - An object containing the parameters for the request. - **name** (string) - Required - The ENS name to get the history for. ### Request Example ```json { "client": "", "parameters": { "name": "ens.eth" } } ``` ### Response #### Success Response (200) - **history** (Array | null) - The history of the name, or null if the name could not be found. #### Response Example ```json { "history": [ { "id": "0x123...", "labelName": "ens", "labelHash": "0xabc...", "name": "ens.eth", "createdAt": 1678886400, "updatedAt": 1678886400, "registration": { "id": "0x456...", "registrant": { "id": "0xdef..." }, "expiryDate": 1709999999 }, "transferrable": true } ] } ``` ``` -------------------------------- ### Run Specific Test File Source: https://github.com/ensdomains/ensjs/blob/main/CLAUDE.md Executes a specific test file using Vitest. Useful for focusing on a particular feature or bug fix. ```bash pnpm vitest src/functions/public/getOwner.test.ts ``` -------------------------------- ### Get Name History from ENS Subgraph Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsSubgraphClient.md Fetches the history of an ENS name from the subgraph. This function requires the ensSubgraphActions extension. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) const result = await client.getNameHistory({ name: 'ens.eth' }) ``` -------------------------------- ### GetPrice API Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Calculates the price for registering a name or an array of names for a specified duration. ```APIDOC ## GET /ensdomains/ensjs/getPrice ### Description Gets the price of a name, or array of names, for a given duration. ### Method GET ### Endpoint /ensdomains/ensjs/getPrice ### Parameters #### Query Parameters - **parameters** (GetPriceParameters) - Required - GetPriceParameters ### Response #### Success Response (200) - **priceData** (object) - Price data object. #### Response Example ```json { "base": 352828971668930335n, "premium": 0n } ``` ``` -------------------------------- ### Get ENS Subgraph Records with Viem Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Fetches ENS records from the subgraph using Viem client. Requires ensSubgraphActions extension. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) const result = await client.getSubgraphRecords({ name: 'ens.eth' }) // { // isMigrated: true, // createdAt: { date: 2019-08-26T05:09:01.000Z, value: 1566796141000 }, // texts: [ 'snapshot', 'url', 'avatar', 'com.twitter', 'com.github' ], // coins: [ '60' ] // } ``` -------------------------------- ### createSubname Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsWalletClient.md Creates a subname. ```APIDOC ### createSubname **createSubname**: (`parameters`) => `Promise`\< \`0x${string}\` Creates a subname ``` -------------------------------- ### Get DNS Owner using ensjs Source: https://github.com/ensdomains/ensjs/blob/main/docs/dns/function.getDnsOwner.md Use this function to retrieve the DNS owner of a name. Ensure you have imported getDnsOwner from '@ensdomains/ensjs/dns'. ```typescript import { getDnsOwner } from '@ensdomains/ensjs/dns' const owner = await getDnsOwner({ name: 'ens.domains' }) // '0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5' ``` -------------------------------- ### ensPublicActions() Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.ensPublicActions.md Extends the viem client with ENS public actions. ```APIDOC ## Function: ensPublicActions() ### Description Extends the viem client with ENS public actions. ### Method Extend (as part of viem client extension) ### Endpoint N/A (Client Extension) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const clientWithEns = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) ``` ### Response #### Success Response (200) `EnsPublicActions` - An object containing ENS-specific public actions. #### Response Example N/A (Client Extension) ``` -------------------------------- ### Get ENS Text Record with Viem Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.createEnsPublicClient.md Retrieves a specific text record for an ENS name using Viem. Requires ensPublicActions extension. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensPublicActions } from '@ensdomains/ensjs' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensPublicActions) const result = await client.getTextRecord({ name: 'ens.eth', key: 'com.twitter', }) // ensdomains ``` -------------------------------- ### Batching Calls with EnsPublicClient Source: https://github.com/ensdomains/ensjs/blob/main/docs/basics/batching-calls.md Use `ensBatch` on an `EnsPublicClient` to batch multiple ENS public method calls. Ensure `EnsPublicClient` is created with the necessary chain and transport configurations. ```typescript import { http } from 'viem' import { mainnet } from 'viem/chains' import { createEnsPublicClient } from '@ensdomains/ensjs' import { getAddressRecord, getTextRecord } from '@ensdomains/ensjs/public' const client = createEnsPublicClient({ chain: mainnet, transport: http(), }) const [ethAddress, twitterUsername] = client.ensBatch( getAddressRecord.batch({ name: 'ens.eth' }), getTextRecord.batch({ name: 'ens.eth', key: 'com.twitter' }), ) /* [ { id: 60, name: 'ETH', value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7' }, 'ensdomains' ] */ ``` -------------------------------- ### Extend viem Client with ENS Subgraph Actions Source: https://github.com/ensdomains/ensjs/blob/main/docs/index/function.ensSubgraphActions.md Use this snippet to extend a viem public client with ENS subgraph actions. Ensure you import `addEnsContracts` and `ensSubgraphActions` from `@ensdomains/ensjs` and chain configurations from `viem`. ```typescript import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts, ensSubgraphActions } from '@ensdomains/ensjs' const clientWithEns = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }).extend(ensSubgraphActions) ``` -------------------------------- ### GET /subgraph/registrant Source: https://github.com/ensdomains/ensjs/blob/main/docs/subgraph/function.getSubgraphRegistrant.md Retrieves the registrant address for a given ENS name from the subgraph. It's recommended to use an API key from TheGraph for optimal performance. ```APIDOC ## GET /subgraph/registrant ### Description Retrieves the registrant address for a given ENS name from the subgraph. It's recommended to use an API key from TheGraph for optimal performance. ### Method GET ### Endpoint /subgraph/registrant ### Parameters #### Query Parameters - **name** (string) - Required - The ENS name to query. ### Request Example ```ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { addEnsContracts } from '@ensdomains/ensjs' import { getSubgraphRegistrant } from '@ensdomains/ensjs/subgraph' const client = createPublicClient({ chain: addEnsContracts(mainnet), transport: http(), }) const result = await getSubgraphRegistrant(client, { name: 'ens.eth' }) // 0xb6E040C9ECAaE172a89bD561c5F73e1C48d28cd9 ``` ### Response #### Success Response (200) - **registrant** (string) - The registrant address, or null if the name was not found. #### Response Example ```json { "registrant": "0xb6E040C9ECAaE172a89bD561c5F73e1C48d28cd9" } ``` ``` -------------------------------- ### Get DNS Import Data Source: https://github.com/ensdomains/ensjs/blob/main/docs/dns/function.getDnsImportData.md Retrieves DNS import data required for proving the value of the _ens TXT record when importing a DNS name. ```APIDOC ## GET /dns/getDnsImportData ### Description Gets DNS import data, used for `importDnsName()`. ### Method GET ### Endpoint /dns/getDnsImportData ### Parameters #### Query Parameters - **name** (string) - Required - The DNS name to import. - **client** (ClientWithEns) - Required - The ENSJS client instance. ### Request Example ```json { "name": "example.eth", "client": "" } ``` ### Response #### Success Response (200) - **data** (object) - DNS import data object, used for proving the value of the `_ens` TXT record. #### Response Example ```json { "data": { "proof": "", "owner": "", "registry": "" } } ``` ``` -------------------------------- ### createSubname() Source: https://github.com/ensdomains/ensjs/blob/main/docs/wallet/function.createSubname.md Creates a subname for a given owner. ```APIDOC ## POST /wallet/createSubname ### Description Creates a subname for a given owner. ### Method POST ### Endpoint /wallet/createSubname ### Parameters #### Request Body - **wallet** (object) - Required - ClientWithAccount - **parameters** (object) - Required - CreateSubnameParameters - **name** (string) - Required - The name of the subname to create, e.g., 'sub.ens.eth' - **owner** (string) - Required - The owner of the subname - **contract** (string) - Required - The contract to use, e.g., 'registry' ### Request Example ```json { "wallet": "viem wallet client", "parameters": { "name": "sub.ens.eth", "owner": "0x...", "contract": "registry" } } ``` ### Response #### Success Response (200) - **transactionHash** (string) - The hash of the transaction used to create the subname. #### Response Example ```json { "transactionHash": "0x..." } ``` ```