# one-names-sdk

> One Names SDK

Latest version **1.0.2** (published 2021-05-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install one-names-sdk
pnpm add one-names-sdk
yarn add one-names-sdk
bun add one-names-sdk
```

Provides the command `one-names-sdk`.

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-05-27 |
| First published | 2021-05-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 268.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | harmony |
| Maintainers | potvik |

## Links

- npm: https://www.npmjs.com/package/one-names-sdk
- Repository: https://github.com/harmony-one/one-names.sdk
- Homepage: https://github.com/harmony-one/one-names.sdk#readme
- Issues: https://github.com/harmony-one/one-names.sdk/issues
- npm.io page: https://npm.io/package/one-names-sdk

## Dependencies (4)

- [web3](https://npm.io/package/web3.md) ^1.3.0
- [@harmony-js/core](https://npm.io/package/@harmony-js/core.md) ^0.1.55
- [eth-ens-namehash](https://npm.io/package/eth-ens-namehash.md) ^2.0.8
- [@ensdomains/ensjs](https://npm.io/package/@ensdomains/ensjs.md) ^2.0.1

## Recent versions

- 1.0.2 (latest) — 2021-05-27
- 1.0.1 — 2021-05-27

## README

# one-names-sdk

### Install instructions

```
npm i one-names-sdk --save
```

## How to use

### 1. Init SDK instance

```js
    import { getHmyClient } from "one-names-sdk";

    const hmyClient = await getHmyClient({
        sdk: "web3",
        nodeURL: "https://api.s0.b.hmny.io",
        chainId: 2,
        ensAddress: "0x23ca23b6f2C40BF71fe4Da7C5d6396EE2C018e6A",
        gasLimit: 6721900,
    });
    
    await hmyClient.addWallet(process.env.PRIVATE_KEY);
```

### 2. Call register methods

```js
  const hmyClient = await getHmyClient({
    sdk: "web3",
    nodeURL: "https://api.s0.b.hmny.io",
    chainId: 2,
    ensAddress: "0x23ca23b6f2C40BF71fe4Da7C5d6396EE2C018e6A",
    gasLimit: 6721900,
  });

  await hmyClient.addWallet(process.env.PRIVATE_KEY);

  const myAddress = hmyClient.getUserAddress();

  console.log("myAddress: ", myAddress);

  const duration = 365 * 24 * 3600; // 1year
  const domain = "12345test";
  const owner = myAddress;
  const secret =
    "0xe6bcec774acd54b71bd49ca5570f4bae074e7d983cad8a3162b480219adecdea";

  console.log(
    "owner: ",
    await hmyClient.methods.ens.name(domain + ".one").getOwner()
  );
  console.log(
    "address: ",
    await hmyClient.methods.ens.name(domain + ".one").getAddress()
  );

  const rentPrice = await hmyClient.methods.rentPrice(domain, duration);

  console.log("1 - rentPrice: ", rentPrice / 1e18);

  const commitment = await hmyClient.methods.makeCommitment(
    domain,
    owner,
    duration,
    secret,
    myAddress
  );

  console.log("2 - commit: ", commitment);

  await hmyClient.methods.commit(commitment);

  console.log("3 - sleep 15 sec");

  await sleep(15);

  console.log("4 - register");

  const res = await hmyClient.methods.register(
    domain,
    owner,
    duration,
    secret,
    myAddress
  );

  console.log("5 - register result: ", res.status);

  console.log(
    "owner: ",
    await hmyClient.methods.ens.name(domain + ".one").getOwner()
  );
  console.log(
    "address: ",
    await hmyClient.methods.ens.name(domain + ".one").getAddress()
  );
````

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