# Working with Domains

Before you can begin interacting with Domains, you will need to obtain a reference to the Domains registry. How you do this depends on the library you are using.

Example code for the Javascript-based APIs (tdnsjs, web3.js, ethjs-tdns, and ethers.js) here expect that they are being run inside a DApp browser, such as Chrome with [metamask installed](https://metamask.github.io/metamask-docs/Main_Concepts/Getting_Started), which exposes the polygon object.

{% tabs %}
{% tab title="ensjs" %}

```javascript
import ENS, { getEnsAddress } from '@ensdomains/ensjs'

const ens = new ENS({ provider, ensAddress: "0x78C9E78D00De510e41c4a36a6325f6D3Eb2aE473" })
```

{% endtab %}

{% tab title="web3.js" %}

```javascript
var Web3 = require("web3")

var accounts = ethereum.enable();
var web3 = new Web3(ethereum);
var ens = web3.eth.ens;
```

{% endtab %}

{% tab title="ethjs-ens" %}

```javascript
const ENS = require('ethjs-ens');
// Currently requires both provider and
// either a network or registryAddress param
var accounts = ethereum.enable();
const ens = new ENS({ ethereum, network: '1' });
```

{% endtab %}

{% tab title="ethers.js" %}

```javascript
var ethers = require('ethers');
var provider = new ethers.providers.Web3Provider(ethereum);
// ENS functionality is provided directly on the core provider object.
```

{% endtab %}

{% tab title="go-ens" %}

```go
import (
  ens "github.com/wealdtech/go-ens/v2"
  ethereum "github.com/ethereum/go-ethereum"
)

// Can dial up a connection through either IPC or HTTP/HTTPS
client, err := ethereum.Dial("/home/ethereum/.ethereum/geth.ipc")
registry, err := ens.Registry(client)
```

{% endtab %}

{% tab title="web3.py" %}

```python
from ens.auto import ns
```

{% endtab %}

{% tab title="web3j" %}

```java
EnsResolver ens = new EnsResolver(web3j, 300 /* sync threshold, seconds */);
```

{% endtab %}
{% endtabs %}

Some web3 libraries - e.g., ethers.js, web3j, and web3.py - have integrated support for name resolution. In these libraries, you can pass in an Domains name anywhere you can supply an address, meaning you do not need to interact directly with their tDNS APIs unless you want to manually resolve names or do other Domains operations.

If no library is available for your platform, you can instantiate the Domains registry contract directly using the interface definition [here](https://github.com/ensdomains/ens/blob/master/contracts/ENS.sol). Addresses for the Domains registry on each supported network are available in the Domains Deployments page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tomi-domain-name-service.gitbook.io/titled/dapp-developer-guide/working-with-domains.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
