Skip to main content

Creating a Subname

Create a subname under an existing ENS name with text records, address records, and metadata.
Label: Follows ENS naming convention with UTS-51 encoding. Can include emojis. See ENSIP-15.
import { ChainName } from "@thenamespace/offchain-manager";

client.createSubname({
  label: "subname",
  parentName: "example.eth",
  texts: [
    { key: "avatar", value: "avatar url..." },
    { key: "name", value: "superman" },
  ],
  addresses: [
    { chain: ChainName.Ethereum, value: "0x123..." },
    { chain: ChainName.Bitcoin, value: "qgds..." },
  ],
  owner: "0x123...",
  metadata: [{ key: "sender", value: "0x123..." }],
});
Parameters:
  • label - Subname label (e.g., “subname” for subname.example.eth)
  • parentName - Parent ENS name
  • texts - Text records (optional)
  • addresses - Address records (optional)
  • metadata - Key-value metadata for filtering (optional)
  • contenthash - Content hash (optional)
  • owner - Owner address (optional)
  • ttl - Time-to-live (optional)
Include the owner field when creating a subname. This allows you to later fetch all subnames owned by a specific address using the SDK or API.

Updating a Subname

Modify text records, address records, content hash, or metadata for an existing subname.
client.updateSubname("superman.namespace.eth", {
  texts: [{ key: "avatar", value: "updated-avatar" }],
});
Parameters:
  • texts - Text records to update (optional)
  • addresses - Address records to update (optional)
  • metadata - Metadata to update (optional)
  • contenthash - New content hash (optional)
  • ttl - Time-to-live (optional)
The ChainName enum maps blockchain networks to their SLIP-0044 coin types. See ChainName for details.
I