Skip to main content

Overview

This guide walks you through creating and using offchain ENS subnames with the @thenamespace/offchain-manager SDK. You’ll be able to create a subname, and then read records.

Prerequisites

  • Node.js 18+ and a package manager (npm or yarn)
  • An ENS name you manage (e.g., myensname.eth)
  • A Namespace API key (from the Namespace App)

Get an API Key

Follow this guide to create and copy your API key from the Namespace App.
1

Install and initialize the SDK

Install the Offchain SDK and dotenv to load your API key from an environment variable:
Initialise the client with the network you want to use and your API key. We recommend setting your API key via an environment variable and keeping it secret by using server-side code.
2

Check if a subname is available

Use isSubnameAvailable before creating a subname to avoid overwriting an existing one.
Expected output (if available):
3

Create the subname with optional records

You can use the owner field to filter subnames by their associated address, enabling efficient reverse lookups (from address to name).
Create a subname under your parent name. You can include text records, address records, owner, and metadata.
Expected output:
4

Filter subnames by owner

We recommend associating a single address with a single subname to do reverse lookup.
Fetch all subnames you own or created by filtering on owner (or by metadata).
Example output:
5

Look up text records

Retrieve a single text record or all text records on a subname.
Example output:
6

Look up address records

Address records are included in the subname response. A simple way to read them is via getFilteredSubnames and then inspecting addresses.
Example output:

Next steps

ENS Client Compatibility

Subnames created with the Offchain SDK can be accessed and resolved using any of the eligible ENS client libraries like wagmi, viem, ethers, and others listed in the ENS Tools & Libraries documentation.
Reverse Resolution Limitation: Offchain subnames do not support reverse resolution, so you cannot fetch a profile from an address. However, you can still set address records on offchain subnames for forward resolution.