# Manage Domains Using Smart Contracts 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. ## Step 1: Select a UNS Registry Smart Contract The [UNS Registry](/smart-contracts/contract-reference/uns-smart-contracts#unsregistry) 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. - [Ethereum Mainnet Registry](https://etherscan.io/address/0x049aba7510f45BA5b64ea9E658E342F904DB358D) - [Polygon Mainnet Registry](https://polygonscan.com/address/0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f) - [Base Mainnet Registry](https://basescan.org/address/0xF6c1b83977DE3dEffC476f5048A0a84d3375d498) For help identifying which Registry to use for which TLD, refer to the `meta` object returned from the [supported TLDs endpoint](https://api.unstoppabledomains.com/resolve/supported_tlds). Use the registry that aligns with the `registrationBlockchain` for your TLD. figure ![polygon registry contract](/images/polygon-registry-contract.png) figcaption polygon registry contract ## Step 2: Open the "Write as Proxy" Tab for the Registry Contract Navigate to the `Contract` tab in either the Etherscan or Polygonscan page of the Registry contract and click on the `Write as Proxy` tab: figure ![polygonscan write as proxy tab](/images/polygonscan-write-as-proxy-tab.png) figcaption polygonscan write as proxy tab ## Step 3: Connect Your Web3 Wallet Click on the `Connect to Web3` button in the `Write as Proxy` tab and connect the wallet associated with the domain: figure ![polygonscan connect wallet](/images/polygonscan-connect-wallet.png) figcaption polygonscan connect wallet figure ![wallet provider list](/images/wallet-provider-list.png) figcaption wallet provider list ## Step 4: Manage the Domain Records Choose the `set` or `setMany` method from the `Write as Proxy` tab section. The `set` method allows you to update a single record, while the `setMany` method allows you to update multiple records simultaneously. figure ![polygonscan set method](/images/polygonscan-set-method.png) figcaption polygonscan set method figure ![polygonscan setMany method](/images/polygonscan-setmany-method.png) figcaption polygonscan setMany method Next, add the record(s) you want to manage to the `key` and `value` fields as a single value for the `set` method or array of values for the `setMany` method. figure ![adding records with setMany](/images/adding-records-with-setmany.png) figcaption adding records with setMany Please see the [Record Reference](/resolution/records-reference) guide and [reference JSON](https://github.com/unstoppabledomains/uns/blob/main/resolver-keys.json) file for all the resolver keys used by the Unstoppable Domains UNS Registry. ## Step 5: Generate the Namehash of the Domain You can generate the [namehash](/getting-started/glossary#namehash) of a domain using the [Resolution Service](https://docs.unstoppabledomains.com/apis/resolution/#operation/DomainsController.getDomain). You can also use [online tools](https://swolfeyes.github.io/ethereum-namehash-calculator/) to calculate the namehash of the domain. ```typescript /** * Resolves the namehash for a given domain. * * @param {string} domain - The domain name to resolve * @returns {Promise} The resolved namehash or null if not found * * @throws {Error} When no namehash can be resolved for the given domain */ async function resolveNamehash( domain: string, ): Promise { try { const response = await axios.get( UNSTOPPABLE_API_BASE_URL + 'domains/' + encodeURIComponent(domain), { headers: { 'Authorization': 'Bearer ' + UNSTOPPABLE_API_KEY } } ); const metadata = response.data.meta; const namehash = metadata['namehash']; if (namehash) return namehash; throw new Error('No namehash found for ' + domain); } catch (error) { console.error('Namehash resolution error:', error); return null; } } ``` After generating the domain namehash, insert it into the `tokenId` field of the `set` or `setMany` method. figure ![adding domain namehash](/images/adding-domain-namehash.png) figcaption adding domain namehash ## Step 6: Execute the Contract Click the `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: figure ![polygonscan transaction details](/images/polygonscan-transaction-details.png) figcaption polygonscan transaction details Congratulations! You have successfully managed your Unstoppable Domain records using smart contracts. Happy hacking!