@habsyr/weth-helper
A simple class for helping to wrap and unwrap Ether.
Last updated 9 months ago by henryharder .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @habsyr/weth-helper 
SYNC missed versions from official npm registry.

WETH Helper (@habsyr/weth-helper)

Exports a helper class WethHelper to simplify interactions with the canonical wrapped Ether (WETH9) contract.

Documentation can be found in the docs/ folder.

Usage

This section will get you started quickly with the WethHelper class.

Install

Add the package to your project.

# with yarn
yarn add @habsyr/weth-helper

# with npm
npm i --save @habsyr/weth-helper

Import

Import the helper class into your codebase.

// ES6+ and TypeScript
import { WethHelper } from "@habsyr/weth-helper";

// CommonJS
const { WethHelper } = require("@habsyr/weth-helper");

Setup

You must instantiate helper instances with a configured Ethereum provider.

Browser

To use in a web3 supported browser, try the following.

const { WethHelper } = require("@habsyr/weth-helper");

(async () => {
    await window.ethereum.enable();

    const wethHelper = new WethHelper(window.ethereum);

    // use any public methods after construction
    const one = wethHelper.toBaseUnits(1);
    const txId = await wethHelper.wrap(one);
})();

Server

For usage in the server (Node.js), try the following.

const { WethHelper } = require("@habsyr/weth-helper");
const Web3 = require("web3");

const {
    ETHEREUM_JSONRPC_URL = "http://localhost:8545",
} = process.env;

const web3 = new Web3(ETHEREUM_JSONRPC_URL);
const wethHelper = new WethHelper(web3.currentProvider);

Develop

  1. Install dependencies (yarn)
  2. Build source (yarn build)
  3. Lint source (yarn lint)
  4. Generate docs (yarn docs)
  5. Run tests against Ganache RPC (yarn test)

License

MIT Licensed.

Written by Henry Harder (@hrharder), 2019.

Contributing

Contributions and issue reports welcome and encourage.

Please feel free to open an issue or a pull request as needed.

Current Tags

  • 0.3.0                                ...           latest (9 months ago)

9 Versions

  • 0.3.0                                ...           9 months ago
  • 0.2.6                                ...           9 months ago
  • 0.2.5                                ...           9 months ago
  • 0.2.4                                ...           9 months ago
  • 0.2.3                                ...           9 months ago
  • 0.2.2                                ...           9 months ago
  • 0.2.1                                ...           9 months ago
  • 0.2.0                                ...           9 months ago
  • 0.1.0                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |