# eraswap-sdk

> Typechain outputs of esn-contracts and utils. Commit tag of KMPARDS/esn-contracts is included in the version.

Latest version **3.0.6** (published 2021-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install eraswap-sdk
pnpm add eraswap-sdk
yarn add eraswap-sdk
bun add eraswap-sdk
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.6 |
| Published | 2021-05-05 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | github.com/zemse |
| Maintainers | eraswapnetwork |

## Links

- npm: https://www.npmjs.com/package/eraswap-sdk
- npm.io page: https://npm.io/package/eraswap-sdk

## Dependencies (2)

- [ethers](https://npm.io/package/ethers.md) ^5.0.26
- [@types/node](https://npm.io/package/@types/node.md) ^14.14.25

## Recent versions

- 3.0.6 (latest) — 2021-05-05
- 3.0.5-commit.37b5ab6e — 2021-02-12
- 3.0.4-commit.3b6d66d0 — 2020-11-20
- 3.0.3-commit.3b6d66d0 — 2020-11-17
- 3.0.2-commit.807ca3ec — 2020-11-16
- 3.0.1-commit.807ca3ec — 2020-11-13
- 3.0.0-commit.807ca3ec — 2020-11-13
- 2.0.5-commit.807ca3ec — 2020-11-11
- 2.0.4-commit.db7234f1 — 2020-11-01
- 2.0.3-commit.f46752c2 — 2020-10-29
- 2.0.2-commit.f46752c2 — 2020-10-24
- 2.0.1-commit.f46752c2 — 2020-10-24
- 2.0.0-commit.cc337c5b — 2020-10-14
- 1.0.7-commit.3757c1c2 — 2020-10-06
- 1.0.6-commit.88934170 — 2020-10-03
- … 6 more at https://npm.io/package/eraswap-sdk/versions

## README

# Era Swap SDK

This kit is intended to make it convenient to access to addresses of smart contracts related to Era Swap and common utilities.

```
$ yarn add eraswap-sdk@latest

or

$ npm i eraswap-sdk@latest
```

> Please note that Era Swap SDK requires that you are using TypeScript 3.8+

## `addresses` bucket: Accessing Contract Addresses

```ts
import { es } from 'eraswap-sdk';

// Get the testing address
const timeallyAddressTesting = es.addresses['development'].ESN.timeallyManager;

// Get the mainnet address
const timeallyAddressMainnet = es.addresses['production'].ESN.timeallyManager;
```

You can use a env variable to easily switch between testnet and mainnet deployments.

## `CustomProvider`

Custom provider is a modification of `ethers.js`'s `JsonRpcProvider` with Kyc Dapp integrated and better errors

```ts
import { es } from 'eraswap-sdk';

// for mainnet
const providerESN = new es.CustomProvider('mainnet');

// for testnet
const providerESN = new es.CustomProvider('testnet');

// or (a preferrable way)

import { CustomProvider } from 'eraswap-sdk';

const providerESN = new CustomProvider('testnet');
```

## `typechain` bucket: Accessing Contract Typings

```ts
import { es } from 'eraswap-sdk';

const timeallyInstance = es.typechain.ESN.TimeAllyManagerFactory.connect(
  es.addresses[process.env.NODE_ENV].ESN.timeallyManager,
  providerESN
);

// another (preferrable) way to import

import { PlasmaManagerFactory } from 'eraswap-sdk/dist/typechain/ETH';
import { TimeAllyManagerFactory } from 'eraswap-sdk/dist/typechain/ESN';

const timeallyInstance = TimeAllyManagerFactory.connect(
  es.addresses[process.env.NODE_ENV].ESN.timeallyManager,
  providerESN
);
```

## General Utils

### Parsing Ethers.js errors.

Errors in v5 have gotten ugly lately. See [ethers-io/ethers.js#871](https://github.com/ethers-io/ethers.js/issues/871). This

```ts
import { es } from 'eraswap-sdk';

try {
  await contract.methodThatThrowError();
} catch (error) {
  const readableError = es.utils.parseEthersJsError(error); // string
  setDisplayMessage(`Error: ${readableError}`);
}
```

### Getting Era Swap Explorer url

```ts
import { es } from 'eraswap-sdk';

const url = es.utils.EraswapInfo.getAddressHref(
  '0xC8e1F3B9a0CdFceF9fFd2343B943989A22517b26'
);
// returns: https://eraswap.info/address/0xC8e1F3B9a0CdFceF9fFd2343B943989A22517b26

const url = es.utils.EraswapInfo.getTxHref(
  '0x200706e0608bec9ad2993b6659df036062e8fbbdc9cc61bd52c61ab106a48f44'
);
// returns: https://eraswap.info/txn/0x200706e0608bec9ad2993b6659df036062e8fbbdc9cc61bd52c61ab106a48f44
```

# License

[MIT](https://github.com/KMPARDS/eraswap-sdk/blob/HEAD/LICENSE)

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