# eal-sdk

> EAL SDK for Node.JS and the Browser

Latest version **0.0.1** (published 2023-08-07) · Apache-2.0 license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-08-07 |
| First published | 2023-08-07 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10.13.0 |
| Dependencies | 3 |
| Unpacked size | 207 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Coiin |
| Maintainers | dragonchain-service-user |
| Keywords | coiin, eal, sdk |

## Links

- npm: https://www.npmjs.com/package/eal-sdk
- Repository: https://github.com/Coiin-Blockchain/coiin-eal-sdk-javascript
- Homepage: https://github.com/Coiin-Blockchain/coiin-eal-sdk-javascript#readme
- Issues: https://github.com/Coiin-Blockchain/coiin-eal-sdk-javascript/issues
- npm.io page: https://npm.io/package/eal-sdk

## Dependencies (3)

- [ini](https://npm.io/package/ini.md) ^1.3.5
- [tslib](https://npm.io/package/tslib.md) ^1.11.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-08-07

## README

# Coiin EAL JS SDK

Talk to your Coiin EAL chain.

## Docs

Full docs for the SDK [can be found here](https://node-sdk-docs.eal.coiin.io/latest).

## Installation

```sh
npm i coiin-eal-sdk --save
```

### Initialize The Client

```javascript
const sdk = require('coiin-eal-sdk');

const main = async () => {
  const client = await sdk.createClient({
    coiinEalId: 'c2dffKwiGj6AGg4zHkNswgEcyHeQaGr4Cm5SzsFVceVv'
  });
  // Do something with the client here
};

main()
  .then(console.log)
  .catch(console.error);
```

### GetBlock

```javascript
const call = await client.getBlock({ blockId: '56841' });

if (call.ok) {
  console.log('Successful call!');
  console.log(`Block: ${call.response}`);
} else {
  console.error('Something went wrong!');
  console.error(`HTTP status code from chain: ${call.status}`);
  console.error(`Error response from chain: ${call.response}`);
}
```

## Configuration

In order to use this SDK, you need to have an Auth Key as well as
an Auth Key ID for a given Coiin EAL ID. It is also strongly suggested that
you supply an endpoint locally so that a remote service isn't called to
automatically discover your coiin eal endpoint. These can be loaded into the
sdk in various ways, and are checked in the following order of precedence:

1. The `createClient` method can be initialized with an object containing
   the parameters `coiinEalId: <ID>`, `authKey: <KEY>`,
   `authKeyId: <KEY_ID>`, and `endpoint: <URL>`

2. The environment variables `COIIN_EAL_ID`,
   `AUTH_KEY`, `AUTH_KEY_ID`, and `COIIN_EAL_ENDPOINT`,
   can be set with the appropriate values

3. An ini-style credentials file can be provided at
   `~/.coiin-eal/credentials` (or on Windows:
   `%LOCALAPPDATA%\coiin-eal\credentials`) where the section name is the
   coiin eal id, with values for `auth_key`, `auth_key_id`, and `endpoint`.
   Additionally, you can supply a value for `coiin_eal_id` in the
   `default` section to initialize the client for a specific chain
   without supplying an ID any other way

```ini
[default]
coiin_eal_id = c2dffKwiGj6AGg4zHkNswgEcyHeQaGr4Cm5SzsFVceVv

[c2dffKwiGj6AGg4zHkNswgEcyHeQaGr4Cm5SzsFVceVv]
auth_key_id = JSDMWFUJDVTC
auth_key = n3hlldsFxFdP2De0yMu6A4MFRh1HGzFvn6rJ0ICZzkE
endpoint = https://35a7371c-a20a-4830-9a59-5d654fcd0a4a.eal.coiin.io

[28VhSgtPhwkhKBgmQSW6vrsir7quEYHdCjqsW6aAYbfrw]
auth_key_id = OGNHGLYIFVUA
auth_key = aS73Si7agvX9gfxnLMh6ack9DEuidKiwQxkqBudXl81
endpoint = https://28567017-6412-44b6-80b2-12876fb3d4f5.eal.coiin.io
```

## Logging

In order to get the logging output of the sdk, a logger must be set (by default all logging is ignored).

In order to set the logger, simply call `.setLogger` on the root of the require/import. For example, if you just wanted to log with `console` (i.e. stdout, stderr, etc), you can set the logger like the following:

```javascript
const sdk = require('coiin-eal-sdk');
sdk.setLogger(console);
```

In that example, `console` can be replaced with any custom logger as long as it implements `log`, `info`, `warn`, `debug`, and `error` functions.

To reset the logger back to default (so it doesn't output anymore), simply called `setLogger()` with no params.

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