# ensjs-v2

> ens.js v2

Latest version **0.0.5** (published 2020-09-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install ensjs-v2
pnpm add ensjs-v2
yarn add ensjs-v2
bun add ensjs-v2
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2020-09-30 |
| First published | 2020-09-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 52 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | makoto_inoue |

## Links

- npm: https://www.npmjs.com/package/ensjs-v2
- npm.io page: https://npm.io/package/ensjs-v2

## Dependencies (9)

- [ethers](https://npm.io/package/ethers.md) ^5.0.13
- [js-sha3](https://npm.io/package/js-sha3.md) ^0.8.0
- [content-hash](https://npm.io/package/content-hash.md) ^2.5.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.4.4
- [@ensdomains/ens](https://npm.io/package/@ensdomains/ens.md) 0.4.3
- [@0xproject/utils](https://npm.io/package/@0xproject/utils.md) ^2.0.2
- [eth-ens-namehash](https://npm.io/package/eth-ens-namehash.md) ^2.0.8
- [@ensdomains/resolver](https://npm.io/package/@ensdomains/resolver.md) 0.2.4
- [@ensdomains/address-encoder](https://npm.io/package/@ensdomains/address-encoder.md) ^0.1.7

## Recent versions

- 0.0.5 (latest) — 2020-09-30
- 0.0.4 — 2020-09-30
- 0.0.3 — 2020-09-30
- 0.0.2 — 2020-09-30
- 0.0.1 — 2020-09-30

## README

# ENS.js V2

## Overview of the API

### Setup

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



const ens = new ENS({ provider, ensAddress: getEnsAddress('1') })

ens.name('resolver.eth').getAddress() // 0x123
```

### exports

```
default - ENS
getEnsAddress
getResolverContract
getENSContract
namehash
labelhash
```

### ENS Interface

```
name(name: String) => Name
```

Returns a Name Object, that allows you to make record queries.

```
resolver(address: EthereumAddress) => Resolver
```

Returns a Resolver Object, allowing you to query names from this specific resolver. Most useful when querying a different resolver that is different than is currently recorded on the registry. E.g. migrating to a new resolver

```
async getName(address: EthereumAddress) => Promise<Name>
```

Returns the reverse record for a particular Ethereum address.

```
async setReverseRecord(name: Name) => Promise<EthersTxObject>
```

Sets the reverse record for the current Ethereum address

### Name Interface

```ts
async getOwner() => Promise<EthereumAddress>
```

Returns the owner/controller for the current ENS name.

```ts
async setOwner(address: EthereumAddress) => Promise<Ethers>
```

Sets the owner/controller for the current ENS name.

```ts
async getResolver() => Promise<EthereumAddress>
```

Returns the resolver for the current ENS name.

```ts
async setResolver(address: EthereumAddress) => Promise<EthereumAddress>
```

Sets the resolver for the current ENS name.

```ts
async getTTL() => Promise<Number>
```

Returns the TTL for the current ENS name.

```ts
async getAddress(coinId: String) => Promise<EthereumAddress>
```

Returns the address for the current ENS name for the coinId provided.

```ts
async setAddress(coinId: String, address: EthereumAddress) => Promise<EthersTxObject>
```

Sets the address for the current ENS name for the coinId provided.

```ts
async getContent() => Promise<ContentHash>
```

Returns the contentHash for the current ENS name.

```ts
async setContenthash(content: ContentHash) => Promise<EthersTxObject>
```

Sets the contentHash for the current ENS name.

```ts
async getText(key: String) => Promise<String>
```

Returns the text record for a given key for the current ENS name.

```ts
async setText(key: String, recordValue: String) => Promise<EthersTxObject>
```

Sets the text record for a given key for the current ENS name.

```ts
async setSubnodeOwner(label: String, newOwner: EthereumAddress) => Promise<EthersTxObject>
```

Sets the subnode owner for a subdomain of the current ENS name.

```ts
async setSubnodeRecord(label: String, newOwner: EthereumAddress, resolver: EthereumAddress, ttl: ?Number) => Promise<EthersTxObject>
```

Sets the subnode owner, resolver, ttl for a subdomain of the current ENS name in one transaction.

```ts
 async createSubdomain(label: String) => Promise<EthersTxObject>
```

Creates a subdomain for the current ENS name. Automatically sets the owner to the signing account.

```ts
async deleteSubdomain(label: String) => Promise<EthersTxObject>
```

Deletes a subdomain for the current ENS name. Automatically sets the owner to "0x0..."

## Resolver Interface

```ts
address
```

Static property that returns current resolver address

```ts
name(name) => Name
```

Returns a Name Object that hardcodes the resolver

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