# susyweb

> Sophon JavaScript API, middleware to talk to a sophon node over RPC

Latest version **0.20.7** (published 2019-06-20) · LGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install susyweb
pnpm add susyweb
yarn add susyweb
bun add susyweb
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.20.7 |
| Published | 2019-06-20 |
| First published | 2019-06-13 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 7.3 MB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | sofdev.com |
| Maintainers | superstring |
| Keywords | sophon, javascript, API |

## Links

- npm: https://www.npmjs.com/package/susyweb
- Repository: https://octonion.institute/susy-js/susyweb.js
- Issues: https://octonion.institute/susy-js/susyweb.js/issues
- npm.io page: https://npm.io/package/susyweb

## Dependencies (5)

- [utf8](https://npm.io/package/utf8.md) ^2.1.1
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.4
- [bignumber.js](https://npm.io/package/bignumber.js.md) git+https://github.com/frozeman/bignumber.js-nolookahead.git
- [xhr2-cookies](https://npm.io/package/xhr2-cookies.md) ^1.1.0
- [xmlhttprequest](https://npm.io/package/xmlhttprequest.md) *

## Recent versions

- 0.20.7 (latest) — 2019-06-20
- 0.16.1 — 2019-06-20
- 0.16.0 — 2019-06-20
- 0.18.4 — 2019-06-20
- 1.0.0-beta.52 — 2019-06-20
- 1.0.0-beta.35 — 2019-06-20
- 1.0.0-beta.37 — 2019-06-19
- 0.17.0-gamma — 2019-06-18
- 0.17.0-beta — 2019-06-18
- 1.0.0-beta.55 — 2019-06-13

## README

# Migration 0.13.0 -> 0.14.0

susyweb.js version 0.14.0 supports [multiple instances of susyweb](https://octonion.institute/susy-js/susyweb.js/issues/297) object.
To migrate to this version, please follow the guide:

```diff
-var susyweb = require('susyweb');
+var SusyWeb = require('susyweb');
+var susyweb = new SusyWeb();
```


# Sophon JavaScript API

[![Join the chat at https://gitter.im/sophon/susyweb.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sophon/susyweb.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This is the Sophon compatible [JavaScript API](https://octonion.institute/susy-go/wiki/JavaScript-API)
which implements the [Generic JSON RPC](https://octonion.institute/susy-go/wiki/JSON-RPC) spec. It's available on npm as a node module, for bower and component as an embeddable js and as a meteor.js package.

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Stories in Ready][waffle-image]][waffle-url]

<!-- [![browser support](https://ci.testling.com/susy-go/sophon.js.png)](https://ci.testling.com/susy-go/sophon.js) -->

You need to run a local Sophon node to use this library.

[Documentation](https://octonion.institute/susy-go/wiki/JavaScript-API)

## Installation

### Node.js

```bash
npm install susyweb
```

### Yarn

```bash
yarn add susyweb
```

### Meteor.js

```bash
meteor add sophon:susyweb
```

### As Browser module

CDN

```html
<script src="https://cdn.jsdelivr.net/gh/sophon/susyweb.js/dist/susyweb.min.js"></script>
```

Bower

```bash
bower install susyweb
```

Component

```bash
component install sophon/susyweb.js
```

* Include `susyweb.min.js` in your html file. (not required for the meteor package)

## Usage
Use the `susyweb` object directly from global namespace:

```js
console.log(susyweb); // {sof: .., shh: ...} // it's here!
```

Set a provider (HttpProvider)

```js
if (typeof susyweb !== 'undefined') {
  susyweb = new SusyWeb(susyweb.currentProvider);
} else {
  // set the provider you want from SusyWeb.providers
  susyweb = new SusyWeb(new SusyWeb.providers.HttpProvider("http://localhost:8545"));
}
```

Set a provider (HttpProvider using [HTTP Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication))

```js
susyweb.setProvider(new susyweb.providers.HttpProvider('http://host.url', 0, BasicAuthUsername, BasicAuthPassword));
```

There you go, now you can use it:

```js
var coinbase = susyweb.sof.coinbase;
var balance = susyweb.sof.getBalance(coinbase);
```

You can find more examples in [`example`](https://octonion.institute/susy-js/susyweb.js/src/branch/master/example) directory.


## Contribute!

### Requirements

* Node.js
* npm

```bash
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy
```

### Building (gulp)

```bash
npm run-script build
```


### Testing (mocha)

```bash
npm test
```

### Community
 - [Gitter](https://gitter.im/sophon/susyweb.js?source=orgpage)
 - [Forum](https://forum.superstring.io/categories/sophon-js)


### Other implementations
 - Python [SusyWeb.py](https://octonion.institute/susy-js/susyweb.py)
 - Haskell [hs-susyweb](https://github.com/airalab/hs-susyweb)
 - Java [susywebj](https://github.com/susywebj/susywebj)
 - Scala [susywebj-scala](https://github.com/mslinn/susywebj-scala)
 - Purescript [purescript-susyweb](https://github.com/f-o-a-m/purescript-susyweb)
 - PHP [susyweb.php](https://github.com/sc0Vu/susyweb.php)
 - PHP [sophon-php](https://github.com/digitaldonkey/sophon-php)


[npm-image]: https://badge.fury.io/js/susyweb.svg
[npm-url]: https://npmjs.org/package/susyweb
[travis-image]: https://travis-ci.org/sophon/susyweb.js.svg
[travis-url]: https://travis-ci.org/sophon/susyweb.js
[dep-image]: https://david-dm.org/sophon/susyweb.js.svg
[dep-url]: https://david-dm.org/sophon/susyweb.js
[dep-dev-image]: https://david-dm.org/sophon/susyweb.js/dev-status.svg
[dep-dev-url]: https://david-dm.org/sophon/susyweb.js#info=devDependencies
[coveralls-image]: https://coveralls.io/repos/sophon/susyweb.js/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/r/sophon/susyweb.js?branch=master
[waffle-image]: https://badge.waffle.io/sophon/susyweb.js.svg?label=ready&title=Ready
[waffle-url]: https://waffle.io/sophon/susyweb.js

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