# ENSjs for Electroneum

The Electroneum ENS javascript library, with [viem](https://github.com/wagmi-dev/viem) under the hood.

This is the [electroneum/ensjs](https://github.com/electroneum/ensjs) fork of [ensdomains/ensjs](https://github.com/ensdomains/ensjs), adapted for **Electroneum ENS**: the registrar TLD is **`.etn`** and the supported chains are Electroneum mainnet (`electroneum`, chain id 52014) and Electroneum testnet (`electroneumTestnet`, chain id 5201420). The companion contracts live in [electroneum/ens-contracts](https://github.com/electroneum/ens-contracts) and are published as [`@etn-sc/ens-contracts`](https://www.npmjs.com/package/@etn-sc/ens-contracts).

## Features

- Super fast response times
- Easy call batchability
- Written in TypeScript
- Full tree-shaking support

## Installation

Install @etn-sc/ensjs, alongside [viem](https://github.com/wagmi-dev/viem).

```sh
npm install @etn-sc/ensjs viem
```

## Getting Started

The most simple way to get started is to create a public ENS client, with the
Electroneum chain and a transport imported from viem. The public client has all
the read functions available on it.

```ts
// Import viem transport, viem chain, and ENSjs
import { http } from 'viem'
import { electroneum } from 'viem/chains'
import { createEnsPublicClient } from '@etn-sc/ensjs'

// Create the client
const client = createEnsPublicClient({
  chain: electroneum,
  transport: http(),
})

// Use the client
const etnAddress = client.getAddressRecord({ name: 'ens.etn' })
```

Note: the `/subgraph` functions are only usable on mainnet (served by the
graph-node at `subgraph.electroneum.com`); there is no ENS subgraph for the
testnet yet.

## Docs

Docs can be found in the upstream repo [here](https://github.com/ensdomains/ensjs/tree/main/docs) — the API is identical apart from the `.etn` TLD and supported chains.
