# kchannel-utils

> Easy-to-use JS library for sending tokens using KChannel in any Node app.

Latest version **0.0.6** (published 2020-12-22) · 0 weekly downloads

## Install

```sh
npm install kchannel-utils
pnpm add kchannel-utils
yarn add kchannel-utils
bun add kchannel-utils
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2020-12-22 |
| First published | 2020-10-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 55.1 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | Patrick Gallagher |
| Maintainers | pi0neerpat |

## Links

- npm: https://www.npmjs.com/package/kchannel-utils
- npm.io page: https://npm.io/package/kchannel-utils

## Dependencies (5)

- [ethers](https://npm.io/package/ethers.md) ^5.0.19
- [lint-staged](https://npm.io/package/lint-staged.md) ^10.5.0
- [eth-sig-util](https://npm.io/package/eth-sig-util.md) ^3.0.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^7.0.7

## Recent versions

- 0.0.6 (latest) — 2020-12-22
- 0.0.5 — 2020-10-28
- 0.0.4 — 2020-10-28
- 0.0.3 — 2020-10-27
- 0.0.2 — 2020-10-27

## README

<h1 align="center">Welcome to kchannel-utils 👋</h1>
<p>
  <img alt="Version" src="https://img.shields.io/npm/v/kchannel-utils" />
  <a href="https://twitter.com/pi0neerpat" target="_blank">
    <img alt="Twitter: pi0neerpat" src="https://img.shields.io/twitter/follow/pi0neerpat.svg?style=social" />
  </a>
</p>

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

> Easy-to-use JS library for sending tokens using KChannel in any Node app.

This package does not require a specific Ethereum library (Web3.js vs. Ethers). Example code for signing messages using both libraries is included in case you aren't familiar with EIP712.

## Install

```sh
yarn add kchannel-utils
```

## Usage

### Step 1. Authenticate with KChannel API

See `authentication.js` for getting an auth token.

### Step 2. Open a Channel

See `channel.js` for opening a channel.

### Step 3. Deposit

Deposit using a standard Ethereum send/transfer to the proper KChannel Verifying contract.

```js
import { domainData } from "kchannel-utils";
const chainId = 1;
const to = domainData[chainId].verifyingContract;

// Deposit ETH
await signer.sendTransaction({ from, to, value });
// Deposit tokens
await depositToken.transfer(to, value);
```

### Step 4. Transfer

See `transfer.js` for transferring tokens. NOTE: The channel must have ETH (gas) to perform a transfer.

### Step 5. Withdraw

Same as a transfer, but the recipient is the deposit contract.

## Questions?

See the `/examples` folder for some examples using React (provider, hooks, etc.).

Check out the [KChannel API Docs](https://docs.kchannels.io/docs/api).

## Feature Requests

_Need-to-have:_

- Add a test-suite
- Better handling for abandoning/failing "open transactions". See `transfer.js`
- Add a `chainId` check for `isAuthenticated()`

_Nice-to-have:_

- Wrap everything in a `class` object so it can be used like this:

```js
// Users
const user = await kutils.user();
await user.send({ tokenAddress, amount, recipient });
```

See [@rtoken/utils](https://github.com/rtoken-project/rtoken-monorepo/tree/master/packages/utils) for another example of this.

## Author

👤 **Patrick Gallagher**

- Website: https://patrickgallagher.dev
  - Twitter: [@pi0neerpat](https://twitter.com/pi0neerpat)
  - GitHub: [@pi0neerpat](https://github.com/pi0neerpat)

## Show your support

Give a ⭐️ if this project helped you!

---

_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_

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