{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-web3/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","partial"]},"type":"markdown"},"seo":{"title":"Reverse Resolve 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":"reverse-resolve-domains-using-smart-contracts","__idx":0},"children":["Reverse Resolve Domains Using Smart Contracts"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide covers how to retrieve the reverse record of UD domains using smart contracts. This process requires using the ABIs built into the Unstoppable Domains UNS smart contract."]},{"$$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-read-as-proxy-tab-for-the-registry-contract","__idx":2},"children":["Step 2: Open the “Read 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":["Read as Proxy"]}," tab:"]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/polygonscan-read-as-proxy.png","alt":"polygonscan read as proxy tab"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan read as proxy tab"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-3-retrieve-the-reverse-record","__idx":3},"children":["Step 3: Retrieve the Reverse Record"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The UNS contract has a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["reverseNameOf()"]}," method that takes in a wallet address and returns the name of the domain that has configured Reverse Resolution to that address."]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/reverse-name-of-abi.png","alt":"polygonscan reverseNameOf method","title":"#width=50%"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan reverseNameOf method"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the wallet address you want to resolve in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addr"]}," field of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["reverseNameOf()"]}," method and click the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Query"]}," button."]},{"$$mdtype":"Tag","name":"figure","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/images/reverse-name-of-abi-response.png","alt":"polygonscan reverseNameOf response"},"children":[]}]},{"$$mdtype":"Tag","name":"figcaption","attributes":{},"children":["polygonscan reverseNameOf response"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["reverseNameOf()"]}," method will return a value of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["''"]}," if there is no reverse record configured for the wallet address provided."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["reverseNameOf()"]}," method will return human-readable domain name."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To calculate ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["namehash"]}," from domain name use namehashing functions:"]},{"$$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":"Heading","attributes":{"level":2,"id":"smart-contract-considerations","__idx":4},"children":["Smart Contract Considerations"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Integrating Reverse Resolution with smart contracts involves using the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["reverseNameOf()"]}," method to retrieve the domain name of the reverse record."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can also integrate Reverse Resolution into your application using libraries that allow you to call smart contracts ABIs like ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://github.com/ethers-io/ethers.js/"},"children":["ethers.js"]}," and ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://github.com/ChainSafe/web3.js"},"children":["web3.js"]},". Here’s an application that integrates Reverse Resolution using ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ethers.js"]},": ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://github.com/Noxturnix/web3udmintfeed.nft"},"children":["https://github.com/Noxturnix/web3udmintfeed.nft"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["An example in JavaScript of integrating Reverse Resolution (using the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://www.npmjs.com/package/ethers"},"children":["ethers.js library"]},"):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const proxyReaderAddress = \"0x423F2531bd5d3C3D4EF7C318c2D1d9BEDE67c680\";\n\n// partial ABI, just for the reverseNameOf method\nconst proxyReaderAbi = [\n    \"function reverseNameOf(address addr) external view returns (string)\",\n];\n\nconst proxyReaderContract = new ethers.Contract(\n    proxyReaderAddress,\n    proxyReaderAbi,\n    provider\n);\n\nconst address = \"0x88bc9b6c56743a38223335fac05825d9355e9f83\";\n\n// call the reverseNameOf method\nconst reverseDomainName = await proxyReaderContract.reverseNameOf(address);\n// jim-unstoppable.x\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"success","name":"Congratulations"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You have successfully integrated Reverse Resolution using smart contracts. Happy Hacking!"]}]}]},"headings":[{"value":"Reverse Resolve Domains Using Smart Contracts","id":"reverse-resolve-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 “Read as Proxy” Tab for the Registry Contract","id":"step-2-open-the-read-as-proxy-tab-for-the-registry-contract","depth":2},{"value":"Step 3: Retrieve the Reverse Record","id":"step-3-retrieve-the-reverse-record","depth":2},{"value":"Smart Contract Considerations","id":"smart-contract-considerations","depth":2}],"frontmatter":{"title":"Smart Contract Integration Guide | UD Developer Portal","description":"This guide covers how to retrieve the reverse record of UD domains using smart contracts. This process requires using the ABIs built into the Unstoppable Domains UNS smart contract.","seo":{"title":"Reverse Resolve Domains Using Smart Contracts"}},"editPage":{"to":"https://github.com/unstoppabledomains/dev-docs/blob/main/web3/smart-contracts/quick-start/reverse-resolve-domains.md"},"lastModified":"2026-04-10T16:45:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/web3/smart-contracts/quick-start/reverse-resolve-domains","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}