# bs-escrow

> A js wrapper around BSToken contract to simplify its consumption

Latest version **1.0.4** (published 2017-02-10) · 0 weekly downloads

## Install

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

## 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.4 |
| Published | 2017-02-10 |
| First published | 2017-01-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Banco Sabadell, S.A |
| Maintainers | bancosabadell |
| Keywords | escrow, ethereum, token |

## Links

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

## Dependencies (3)

- [bluebird](https://npm.io/package/bluebird.md) ^3.4.6
- [bs-token](https://npm.io/package/bs-token.md) ^1.0.5
- [contract-deployer](https://npm.io/package/contract-deployer.md) ^1.0.0

## Recent versions

- 1.0.4 (latest) — 2017-02-10
- 1.0.3 — 2017-02-10
- 1.0.2 — 2017-02-08
- 1.0.1 — 2017-02-03
- 1.0.0 — 2017-01-31

## README

# bs-token

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

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

## Usage

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

### Initialization
Import BSEscrow module and create an instance passing by constructor a Web3 instance, a [BSToken](https://github.com/BancoSabadell/bs-token) instance and a `config` object with the next values:

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

### Api consumption

#### *Calls*

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

**`getEscrow(assetId)`** returns an object representing an escrow containing these properties: buyer, seller, assetPrice and state (0 = Held, 1 = Cancelled, 2 = Fulfilled, 3 = BuyerProposeCancellation, 4 = SellerDisagreeProposalCancellation).

#### *Transactions*

**`createEscrow(buyer, buyerPass, seller, assetPrice, assetId)`** the merchant creates an escrow.

**`cancelEscrow(passwordSeller, assetId)`** the seller cancels an existing escrow.

**`cancelEscrowProposal(passwordBuyer, assetId)`** the buyer makes a proposal to cancel the escrow.

**`validateCancelEscrowProposal(passwordSeller, assetId, validate)`** the seller validates a proposal of cancellation.

**`cancelEscrowArbitrating(passwordOwner, assetId)`** the merchant cancels the escrow using arbitration when the escrow has been reached a conflict state.

**`fulfillEscrow(passwordBuyer, assetId)`** the buyer fulfills the escrow.

**`fulfillEscrowArbitrating(passwordOwner, assetId)`** the merchant fulfills the escrow using arbitration when the escrow has been reached a conflict state.

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