# bs-token

> A js wrapper around BSToken contract to simplify its consumption

Latest version **1.0.8** (published 2017-02-22) · 0 weekly downloads

## Install

```sh
npm install bs-token
pnpm add bs-token
yarn add bs-token
bun add bs-token
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2017-02-22 |
| First published | 2017-01-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Banco Sabadell, S.A |
| Maintainers | bancosabadell |
| Keywords | ethereum, blockchain, contract, solidity, web3 |

## Links

- npm: https://www.npmjs.com/package/bs-token
- Repository: https://github.com/BancoSabadell/bs-token
- Homepage: https://github.com/BancoSabadell/bs-token#readme
- Issues: https://github.com/BancoSabadell/bs-token/issues
- npm.io page: https://npm.io/package/bs-token

## Dependencies (6)

- [solc](https://npm.io/package/solc.md) ^0.4.6
- [web3](https://npm.io/package/web3.md) ^0.16.0
- [eslint](https://npm.io/package/eslint.md) ^3.12.2
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^4.0.0
- [bs-token-data](https://npm.io/package/bs-token-data.md) ^1.0.6
- [contract-deployer](https://npm.io/package/contract-deployer.md) ^1.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2017-02-22
- 1.0.7 — 2017-02-10
- 1.0.6 — 2017-02-10
- 1.0.5 — 2017-02-10
- 1.0.4 — 2017-02-08
- 1.0.3 — 2017-02-02
- 1.0.2 — 2017-01-31
- 1.0.1 — 2017-01-30
- 1.0.0 — 2017-01-30

## README

# bs-token

### A js wrapper around BSToken contract to simplify its consumption.

## Installation
```bash
npm install bs-token
```

## Usage

### Clarifications
* Every method of BSToken's api has been promisified.
* Some of its methods require to call `personal` under the hood in order to unlock an account.

### Initialization
Import BSToken module and create an instance passing by constructor a Web3 instance as long as a `config` object with the next values:

```javascript
const BSToken = require('bs-token');
const lib = new BSToken(web3, {
	    admin: {
	        account: admin,
	        password: password
	    },
	    contractBSToken: {
	        abi: abi,
	        address: address
	    }
	}
);
```

### Api consumption

#### *Calls*

**`balanceOf(targetAddress)`** returns the total amount of tokens available for the specified address.

**`allowance(spender, passSpender, from, to, amount)`** returns the total amount of tokens available for the specified address.

**`frozenAccount(target)`** returns a boolean represeting the state of a given account.

#### *Transactions*

**`transfer(from, passFrom, to, amount)`** send tokens from one address to another.

**`approve(from, passFrom, spender, amount)`** allow spender to withdraw from a given account up to the value amount.

**`approveAndCall(from, passFrom, spender, to, id, amount)`** approve and then communicate the approved contract in a single tx.

**`transferFrom(spender, passSpender, from, to, amount)`** used for a withdraw workflow, allowing contracts to send tokens on behalf the from address.

**`cashOut(targetAddress, pass, amount, bankAccount)`** withdraw a given amount of tokens to the specified bank account.

**`freezeAccount(target, freeze)`** freeze or unfreeze the target address in order to prevent any kind of interaction with the system.

**`startEmergency`** start an emergency state whichs preevents the whole system from performing any kind of interaction.

**`stopEmergency`** stop the emergency state.

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