{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-web3/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","partial"]},"type":"markdown"},"seo":{"title":"Manage Domains Using Smart Contracts","description":"The developer documentation portal and API reference for Unstoppable Domains.","siteUrl":"https://docs.unstoppabledomains.com","keywords":"unstoppable domains developer portal, api reference docs","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"manage-domains-using-smart-contracts","__idx":0},"children":["Manage Domains Using Smart Contracts"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide covers how to manage UD domain records using proxy contracts. This process requires using the Etherscan, Polygonscan, and Basescan user interface to write and execute contracts."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-1-select-a-uns-registry-smart-contract","__idx":1},"children":["Step 1: Select a UNS Registry Smart Contract"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/web3/smart-contracts/contract-reference/uns-smart-contracts#unsregistry"},"children":["UNS Registry"]}," smart contract is where domain owners store their data and is a map of domain namehashes to key-value dictionaries of records. Choose one of the Unstoppable Registry smart contracts to interact with below."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://etherscan.io/address/0x049aba7510f45BA5b64ea9E658E342F904DB358D"},"children":["Ethereum Mainnet Registry"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://polygonscan.com/address/0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f"},"children":["Polygon Mainnet Registry"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://basescan.org/address/0xF6c1b83977DE3dEffC476f5048A0a84d3375d498"},"children":["Base Mainnet Registry"]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For help identifying which Registry to use for which TLD, refer to the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["meta"]}," object returned from the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://api.unstoppabledomains.com/resolve/supported_tlds"},"children":["supported TLDs endpoint"]},". Use the registry that aligns with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["registrationBlockchain"]}," for your TLD."]}]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygon-registry-contract.png","alt":"polygon registry contract"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygon registry contract"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-2-open-the-write-as-proxy-tab-for-the-registry-contract","__idx":2},"children":["Step 2: Open the \"Write as Proxy\" Tab for the Registry Contract"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Contract"]}," tab in either the Etherscan or Polygonscan page of the Registry contract and click on the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Write as Proxy"]}," tab:"]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygonscan-write-as-proxy-tab.png","alt":"polygonscan write as proxy tab"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan write as proxy tab"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-3-connect-your-web3-wallet","__idx":3},"children":["Step 3: Connect Your Web3 Wallet"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Click on the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Connect to Web3"]}," button in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Write as Proxy"]}," tab and connect the wallet associated with the domain:"]},{"$$mdtype":"Tag","name":"figure","attributes":{"className":"half-inline-block"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygonscan-connect-wallet.png","alt":"polygonscan connect wallet"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan connect wallet"]}]},{"$$mdtype":"Tag","name":"figure","attributes":{"className":"half-inline-block"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/wallet-provider-list.png","alt":"wallet provider list"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["wallet provider list"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-4-manage-the-domain-records","__idx":4},"children":["Step 4: Manage the Domain Records"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Choose the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["set"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setMany"]}," method from the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Write as Proxy"]}," tab section. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["set"]}," method allows you to update a single record, while the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setMany"]}," method allows you to update multiple records simultaneously."]},{"$$mdtype":"Tag","name":"figure","attributes":{"className":"half-inline-block"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygonscan-set-method.png","alt":"polygonscan set method"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan set method"]}]},{"$$mdtype":"Tag","name":"figure","attributes":{"className":"half-inline-block"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygonscan-setmany-method.png","alt":"polygonscan setMany method"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan setMany method"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Next, add the record(s) you want to manage to the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["value"]}," fields as a single value for the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["set"]}," method or array of values for the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setMany"]}," method."]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/adding-records-with-setmany.png","alt":"adding records with setMany"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["adding records with setMany"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Please see the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/web3/resolution/records-reference"},"children":["Record Reference"]}," guide and ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://github.com/unstoppabledomains/uns/blob/main/resolver-keys.json"},"children":["reference JSON"]}," file for all the resolver keys used by the Unstoppable Domains UNS Registry."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-5-generate-the-namehash-of-the-domain","__idx":5},"children":["Step 5: Generate the Namehash of the Domain"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can generate the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/web3/getting-started/glossary#namehash"},"children":["namehash"]}," of a domain using the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/web3/apis/resolution/openapi#operation/DomainsController.getDomain"},"children":["Resolution Service"]},". You can also use ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://swolfeyes.github.io/ethereum-namehash-calculator/"},"children":["online tools"]}," to calculate the namehash of the domain."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"/**\n * Resolves the namehash for a given domain.\n * \n * @param {string} domain - The domain name to resolve\n * @returns {Promise<string | null>} The resolved namehash or null if not found\n * \n * @throws {Error} When no namehash can be resolved for the given domain\n */\nasync function resolveNamehash(\n  domain: string, \n): Promise<string | null> {\n\n  try {\n    const response = await axios.get(\n      UNSTOPPABLE_API_BASE_URL + 'domains/' + encodeURIComponent(domain), \n      {\n      headers: { 'Authorization': 'Bearer ' + UNSTOPPABLE_API_KEY }\n      }\n    );\n\n    const metadata = response.data.meta;\n      \n    const namehash = metadata['namehash'];\n\n    if (namehash) return namehash;\n\n    throw new Error('No namehash found for ' + domain);\n  } catch (error) {\n    console.error('Namehash resolution error:', error);\n    return null;\n  }\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After generating the domain namehash, insert it into the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tokenId"]}," field of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["set"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setMany"]}," method."]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/adding-domain-namehash.png","alt":"adding domain namehash"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["adding domain namehash"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-6-execute-the-contract","__idx":6},"children":["Step 6: Execute the Contract"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Click the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Write"]}," button to sign the transaction and execute the contract. After signing the transaction, you can view its details on the blockchain explorer, like so:"]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygonscan-transaction-details.png","alt":"polygonscan transaction details","title":"#width=50%"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan transaction details"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"success","name":"Congratulations!"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You have successfully managed your Unstoppable Domain records using smart contracts. Happy hacking!"]}]}]},"headings":[{"value":"Manage Domains Using Smart Contracts","id":"manage-domains-using-smart-contracts","depth":1},{"value":"Step 1: Select a UNS Registry Smart Contract","id":"step-1-select-a-uns-registry-smart-contract","depth":2},{"value":"Step 2: Open the \"Write as Proxy\" Tab for the Registry Contract","id":"step-2-open-the-write-as-proxy-tab-for-the-registry-contract","depth":2},{"value":"Step 3: Connect Your Web3 Wallet","id":"step-3-connect-your-web3-wallet","depth":2},{"value":"Step 4: Manage the Domain Records","id":"step-4-manage-the-domain-records","depth":2},{"value":"Step 5: Generate the Namehash of the Domain","id":"step-5-generate-the-namehash-of-the-domain","depth":2},{"value":"Step 6: Execute the Contract","id":"step-6-execute-the-contract","depth":2}],"frontmatter":{"title":"Manage Domains Using Smart Contracts Guide | UD Developer Portal","description":"This guide covers how to manage UD domain records using the Etherscan, Polygonscan, and Basescan user interfaces to write and execute proxy contracts.","redirects":{"/manage-domains/managing-domains-using-contracts/":{}},"seo":{"title":"Manage Domains Using Smart Contracts"}},"editPage":{"to":"https://github.com/unstoppabledomains/dev-docs/blob/main/web3/smart-contracts/quick-start/manage-domain-records.md"},"lastModified":"2026-04-10T16:45:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/web3/smart-contracts/quick-start/manage-domain-records","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}