🥷
Namespace
  • [ Introduction ]
    • ENS
    • Namespace
  • Official Links
  • [ Dapps ]
    • Overview
    • Onchain Subs (App)
      • Search & Register
      • Wizard
        • Listing an ENS Name
        • Features List
      • ENS Widget
      • Farcaster Frames
        • Default Frame
        • Custom Frame
    • Offchain Subs (DevPortal)
      • Subname create/manage
      • Resolver set
      • API keys
  • How-to Guides and Demos
  • [ Dev Docs ]
    • SDK
      • Offchain Manager
        • Installation
        • Generate API key
        • Create or Update Subname
        • DeleteSubname
        • IsSubnameAvailable
        • GetFilteredSubnames
        • AddressRecords
          • ChainName
        • TextRecords
        • DataRecords
      • Indexer Manager
        • Installation
        • Methods
        • GetL2Subname
        • GetL2Subnames
      • Mint Manager
        • Installation
        • GetMintDetails
        • GetMintTransactionParameters
        • IsSubnameAvailable
        • How To Mint L1 & L2 subname via mint-manager
      • Namespace Client (deprecated)
        • Installation
        • GetListedName
        • GetMintDetails
        • GetMintTransactionParameters
        • IsSubnameAvailable
        • GenerateAuthToken
    • APIs
      • Offchain Manager
      • Mint Manager
    • Infrastructure
      • Namespace L2 Subnames
  • [ ecosystem ]
    • Use Cases
  • [ Jobs ]
    • 🧑‍💻 Full-Stack Dev
    • 🥷 Dev-Rel Lead
    • 💼 BD Lead
Powered by GitBook
On this page
  • CreateSubname
  • Request Interface
  • Usage Example
  • UpdateSubname
  • Request Interface
  • Usage Example
  1. [ Dev Docs ]
  2. SDK
  3. Offchain Manager

Create or Update Subname

CreateSubname

The createSubname method allows you to create a subname under an existing ENS name. It accepts a CreateSubnameRequest object containing all the necessary data for the subname, including text records, address records, and other metadata.

Request Interface

import { ChainName } from "@namespacesdk/offchain-manager"

export interface CreateSubnameRequest {
  parentName: string;
  label: string;
  texts?: KeyValueRequest[];
  addresses?: AddressRecordRequest[];
  metadata?: KeyValueRequest[];
  contenthash?: string;
  owner?: string;
}

export interface KeyValueRequest {
  key: string;
  value: string;
}

export interface AddressRecordRequest {
  chain: ChainName;
  value: string;
}

Chain Mapping

Usage Example

import { ChainName } from "@namespacesdk/offchain-manager"

client.createSubname({
  label: "subname",
  parentName: "example.eth",
  textRecords: [
    { key: "avatar", value: "avatar url..." },
    { key: "name", value: "superman"}
  ],
  addressRecords: [
    { chain: ChainName.Ethereum, value: "0x123..." },
    { chain: ChainName.Bitcoin, value: "qgds..." }
  ]
});

UpdateSubname

The updateSubname method allows you to update an existing subname's data, including text records, address records, content hash, and metadata.

Request Interface

export interface UpdateSubnameRequest {
  texts?: TextRecord[];
  addresses?: AddressRecord[];
  metadata?: TextRecord[];
  contenthash?: string;
  ttl?: number;
}

Usage Example

client.updateSubname("superman.namespace.eth", {
  textRecords: [
    { key: "avatar", value: "updated-avatar" }
  ],
});
PreviousGenerate API keyNextDeleteSubname

Last updated 11 hours ago

The enum is used to map blockchain networks to their corresponding SLIP-0044 coin types, which are used internally by ENS to store address records.

ChainName