0.0.6 • Published 3 years ago

kchannel-utils v0.0.6

Weekly downloads
20
License
-
Repository
-
Last release
3 years ago

All Contributors

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

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.

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.

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:
// Users
const user = await kutils.user();
await user.send({ tokenAddress, amount, recipient });

See @rtoken/utils for another example of this.

Author

👤 Patrick Gallagher

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator