Creating a Subname

Label: The label of the subname follows the ENS naming convention. It follows UTS-51 encoding and can include emojis. See ENSIP-15 for more details.
Use createSubname to add a subname under an existing ENS name.
You can include text records, address records, and metadata.
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..." }],
});
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.

Parameters

  • label: Subname label (e.g., "subname" for subname.example.eth)
  • parentName: Parent ENS name
  • texts: Array of key-value text records. (optional)
  • addresses: Array of address records. (optional)
  • metadata: Array of key-value metadata. It can be used to filter out the subnames later. (optional)
  • contenthash: Content hash (optional)
  • owner: Owner address (optional)
  • ttl: Time-to-live. (optional)

Updating a Subname

Use updateSubname to 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: Array of text records to update (optional)
  • addresses: Array of address records to update (optional)
  • metadata: Array of key-value metadata to update. It can be used to filter out the subnames later. (optional)
  • contenthash: New content hash (optional)
  • ttl: Time-to-live (optional)
The ChainName enum maps blockchain networks to their SLIP-0044 coin types for address records. See the ChainName page for more details.