# @ethereum-waffle/ens

> A mock ens implementation for testing.

Latest version **4.0.3** (published 2023-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ethereum-waffle/ens
pnpm add @ethereum-waffle/ens
yarn add @ethereum-waffle/ens
bun add @ethereum-waffle/ens
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2023-01-26 |
| First published | 2020-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10.0 |
| Dependencies | 0 |
| Unpacked size | 2.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 959 |
| Author | Marek Kirejczyk |
| Maintainers | ethworks |
| Keywords | ethereum, smart-contracts, solidity, testing, javascript, typescript, library, ens |

## Links

- npm: https://www.npmjs.com/package/@ethereum-waffle/ens
- Repository: https://github.com/EthWorks/Waffle
- Issues: https://github.com/EthWorks/Waffle/issues
- npm.io page: https://npm.io/package/@ethereum-waffle/ens

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 4.0.3 (latest) — 2023-01-26
- 4.0.3-dev.238c11c (dev) — 2023-10-12
- 4.0.2 (alpha) — 2022-08-19
- 3.0.0-beta.3 (beta) — 2020-06-12
- 4.0.3-dev.efd5f2a — 2023-10-12
- 4.0.3-dev.0915e72 — 2023-02-15
- 4.0.3-dev.4740ec6 — 2023-02-06
- 4.0.3-dev.a1d89d0 — 2023-01-27
- 4.0.3-dev.f8ca718 — 2023-01-26
- 4.0.3-dev.13d1af0 — 2023-01-26
- 4.0.3-dev.0bc9af4 — 2023-01-26
- 4.0.3-dev.166b72c — 2023-01-26
- 4.0.3-dev.a50814e — 2023-01-24
- 4.0.3-dev.4d27a34 — 2023-01-23
- 4.0.3-dev.e1d3ccd — 2023-01-11
- … 130 more at https://npm.io/package/@ethereum-waffle/ens/versions

## README

![CI](https://github.com/EthWorks/Waffle/workflows/CI/badge.svg)
[![](https://img.shields.io/npm/v/@ethereum-waffle/ens.svg)](https://www.npmjs.com/package/@ethereum-waffle/ens)

![Ethereum Waffle](https://raw.githubusercontent.com/EthWorks/Waffle/master/docs/source/logo.png)

# @ethereum-waffle/ens

A simple `ENS` for testing.

## Installation

In the current version of waffle (v2.x.x) you will install this package as a dependency of the main waffle package - `ethereum-waffle`.

```
yarn add --dev ethereum-waffle
npm install --save-dev ethereum-waffle
```

If you want to use this package directly, please install it via:
```
yarn add --dev @ethereum-waffle/ens
npm install --save-dev @ethereum-waffle/ens
```

## Feature overview

**NOTE**: You do not need to use this package directly. You can install it through the main package (`ethereum-waffle`) and use it instead.

### ENS

The `ENS` class allows to create ENS domains for testing.

It will deploy ENS smart contracts system to your test node.

To create `ENS`, you should submit your `wallet`, available in `MockProvider` class in package `@ethereum-waffle/provider`.

You can read more about ENS [in the ENS's documentation](https://docs.ens.domains/).

### Examples:
Creating ENS:
```ts
import {MockProvider} from '@ethereum-waffle/provider';
import {deployENS, ENS} from '@ethereum-waffle/ens';

const provider = new MockProvider();
const [wallet] = provider.getWallets();
const ens: ENS = await deployENS(wallet);
```

### Usage

Use `createTopLevelDomain` function to create a top level domain:

```ts
await ens.createTopLevelDomain('test');
```

Use `createSubDomain` function for creating a sub domain:

```ts
await ens.createSubDomain('ethworks.test');
```

Also, it's possible to create a sub domain recursively, if the top domain doesn't exist, by specifying the appropriate option:

```ts
await ens.createSubDomain('ethworks.tld', {recursive: true});
```

Use `setAddress` function for setting address for the domain:

```ts
await ens.setAddress('vlad.ethworks.test', '0x001...03');
```
Also, it's possible to set an address for the domain recursively, if the domain doesn't exist, by specifying the appropriate option:

```ts
await ens.setAddress('vlad.ethworks.tld', '0x001...03', {recursive: true});
```

Use `setAddressWithReverse` function for setting address for the domain and make this domain reverse. Add recursive option if the domain doesn't exist:

```ts
await ens.setAddressWithReverse('vlad.ethworks.tld', wallet, {recursive: true});
```

---
_Source: https://npm.io/package/@ethereum-waffle/ens · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
