# ethereum-web-token

> EWT bundles Ethereum function-calls into [JWT](https://jwt.io/)-like tokens. It simplifies the use of ECDSA signatures for webapps and the development of [Smart Oracles](https://github.com/codius/codius/wiki/Smart-Oracles:-A-Simple,-Powerful-Approach-to-S

Latest version **0.1.12** (published 2017-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install ethereum-web-token
pnpm add ethereum-web-token
yarn add ethereum-web-token
bun add ethereum-web-token
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.12 |
| Published | 2017-03-22 |
| First published | 2016-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Johann Barbie |
| Maintainers | johba |
| Keywords | JWT, Ethereum, ABI |

## Links

- npm: https://www.npmjs.com/package/ethereum-web-token
- Repository: https://github.com/cosign-io/ether-token-js
- Homepage: https://github.com/cosign-io/ether-token-js#readme
- Issues: https://github.com/cosign-io/ether-token-js/issues
- npm.io page: https://npm.io/package/ethereum-web-token

## Dependencies (7)

- [bn.js](https://npm.io/package/bn.js.md) ^4.11.6
- [js-sha3](https://npm.io/package/js-sha3.md) ^0.5.2
- [base64url](https://npm.io/package/base64url.md) ^2.0.0
- [es6-promise](https://npm.io/package/es6-promise.md) ^3.2.1
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^2.3.0
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^4.5.0
- [ecdsa-sig-formatter](https://npm.io/package/ecdsa-sig-formatter.md) ^1.0.7

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 0.1.12 (latest) — 2017-03-22
- 0.1.11 — 2017-02-06
- 0.1.10 — 2017-02-06
- 0.1.9 — 2016-10-01
- 0.1.8 — 2016-10-01
- 0.1.7 — 2016-08-30
- 0.1.6 — 2016-08-19
- 0.1.5 — 2016-08-19
- 0.1.4 — 2016-08-18
- 0.1.3 — 2016-08-18
- 0.1.2 — 2016-08-18
- 0.1.1 — 2016-08-18
- 0.1.0 — 2016-08-18

## README

# Etherem Web Token

EWT bundles Ethereum function-calls into [JWT](https://jwt.io/)-like tokens. It simplifies the use of ECDSA signatures for webapps and the development of [Smart Oracles](https://github.com/codius/codius/wiki/Smart-Oracles:-A-Simple,-Powerful-Approach-to-Smart-Contracts).

## Installation

Install the package with `npm i -S ethereum-web-token` from the [npm registry ethereum-web-token](https://www.npmjs.com/package/ethereum-web-token)


## Usage

### Create and Sign a Token

```javascript
import EWT from 'ethethereum-web-token';

let ABI = [{
  type: 'function', name: 'test',
  inputs: [{ type: 'bool' }, { type: 'string' }]
}];
let priv = '...';

new EWT(ABI).test(true, 'string').sign(priv);

=> 'aaaaaa.bbbbbb.cccccc'
```

### Signed Token Example

`eyJ0eXBlIjoiRVdUIiwiYWxnIjoiRVMyNTZrIn0`.`eyJ0ZXN0IjpbeyJib29sIjp0cnVlfSx7InN0cmluZyI6ImpvaGJhIn1dfQ`.`Xm0gkO3-jeAxsLU35g60hALU3CrIYQRFnyGv5vbdCDRlB1yABF8Qu8B9pjbIDwh7hfI_d_O5aQoZNib7WqOeLA` 

encodes

```js
{
  header: { type: 'EWT', alg: 'ES256k' },
  payload: { test: [ { bool: true }, { string: 'johba' } ] },
  sig: {
    v: 27,
    r: '5e6d2090edfe8de031b0b537e60eb48402d4dc2ac86104459f21afe6f6dd0834',
    s: '65075c80045f10bbc07da636c80f087b85f23f77f3b9690a193626fb5aa39e2c'
  }
}
```


### Parse a Token

```javascript
import EWT from 'ethethereum-web-token';

EWT.parse('aaaaaa.bbbbbb.cccccc');

=> {
  values: [true, 'string'],
  signer: '...' //should match address of priv
}
```

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