# eonacore-wallet-client

> Client for eonacore-service

Latest version **1.0.0** (published 2023-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install eonacore-wallet-client
pnpm add eonacore-wallet-client
yarn add eonacore-wallet-client
bun add eonacore-wallet-client
```

## 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.0 |
| Published | 2023-07-31 |
| First published | 2023-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 13 |
| Unpacked size | 1020.9 KB |
| Known vulnerabilities | 0 (+7 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | murmuri |

## Links

- npm: https://www.npmjs.com/package/eonacore-wallet-client
- npm.io page: https://npm.io/package/eonacore-wallet-client

## Dependencies (13)

- [ajv](https://npm.io/package/ajv.md) 6.12.0
- [sjcl](https://npm.io/package/sjcl.md) 1.0.3
- [async](https://npm.io/package/async.md) 0.9.2
- [bip38](https://npm.io/package/bip38.md) 1.4.0
- [lodash](https://npm.io/package/lodash.md) 4.17.20
- [superagent](https://npm.io/package/superagent.md) 5.2.2
- [typescript](https://npm.io/package/typescript.md) 4.9.4
- [preconditions](https://npm.io/package/preconditions.md) 2.2.3
- [eonacore-crypto](https://npm.io/package/eonacore-crypto.md) 1.0.0
- [eonacore-mnemonic](https://npm.io/package/eonacore-mnemonic.md) 1.0.0
- [source-map-loader](https://npm.io/package/source-map-loader.md) 0.2.4
- [source-map-support](https://npm.io/package/source-map-support.md) 0.5.19
- [json-stable-stringify](https://npm.io/package/json-stable-stringify.md) 1.0.1

## Recent versions

- 1.0.0 (latest) — 2023-07-31

## README

# eonacore-wallet-client
## Description

This package communicates with TWS using the REST API. All REST endpoints are wrapped as simple async methods. All relevant responses from BWS are checked independently by the peers, thus the importance of using this library when talking to a third party BWS instance.

## Get Started

You can start using eonacore-wallet-client: by running `npm install eonacore-wallet-client` from your console.

## Example

Start your own local TWS instance. In this example we assume you have `eonacore-wallet-service` running on your `localhost:3232`.

Then create two files `irene.js` and `tomas.js` with the content below:

### **irene.js**

``` javascript
var Client = require('eonacore-wallet-client');


var fs = require('fs');
var TWS_INSTANCE_URL = 'http://localhost:3232/tws/api'

var client = new Client({
  baseUrl: TWS_INSTANCE_URL,
  verbose: false,
});

client.createWallet("My Wallet", "Irene", 2, 2, {network: 'testnet'}, function(err, secret) {
  if (err) {
    console.log('error: ',err);
    return
  };
  // Handle err
  console.log('Wallet Created. Share this secret with your copayers: ' + secret);
  fs.writeFileSync('irene.dat', client.export());
});
```

### **tomas.js**

``` javascript

var Client = require('eonacore-wallet-client');


var fs = require('fs');
var TWS_INSTANCE_URL = 'http://localhost:3232/bws/api'

var secret = process.argv[2];
if (!secret) {
  console.log('./tomas.js <Secret>')

  process.exit(0);
}

var client = new Client({
  baseUrl: TWS_INSTANCE_URL,
  verbose: false,
});

client.joinWallet(secret, "Tomas", {}, function(err, wallet) {
  if (err) {
    console.log('error: ', err);
    return
  };

  console.log('Joined ' + wallet.name + '!');
  fs.writeFileSync('tomas.dat', client.export());


  client.openWallet(function(err, ret) {
    if (err) {
      console.log('error: ', err);
      return
    };
    console.log('\n\n** Wallet Info', ret); //TODO

    console.log('\n\nCreating first address:', ret); //TODO
    if (ret.wallet.status == 'complete') {
      client.createAddress({}, function(err,addr){
        if (err) {
          console.log('error: ', err);
          return;
        };

        console.log('\nReturn:', addr)
      });
    }
  });
});
```

Install `eonacore-wallet-client` before start:

```sh
npm i eonacore-wallet-client
```

Create a new wallet with the first script:

```sh
$ node irene.js
info Generating new keys
 Wallet Created. Share this secret with your copayers: JbTDjtUkvWS4c3mgAtJf4zKyRGzdQzZacfx2S7gRqPLcbeAWaSDEnazFJF6mKbzBvY1ZRwZCbvT
```

Join to this wallet with generated secret:

```sh
$ node tomas.js JbTDjtUkvWS4c3mgAtJf4zKyRGzdQzZacfx2S7gRqPLcbeAWaSDEnazFJF6mKbzBvY1ZRwZCbvT
Joined My Wallet!

Wallet Info: [...]

Creating first address:

Return: [...]

```

Note that the scripts created two files named `irene.dat` and `tomas.dat`. With these files you can get status, generate addresses, create proposals, sign transactions, etc.

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