Catalog npm
Back to packageRELEASE DETAILS

1.7.3

npm

@0xcert/wanchain-utils

General Wanchain utility module with helper functions for the Wanchain blockchain.

0xcertassetblockchaincurrencyerc-20erc-721frameworkfungiblejavascriptlibrariesnodejsnon-fungiblenpmnuxtjsprotocolsmart-contract
All keywords (23)
tokentypescriptvaluevaluesvuejswanchainzxc
Published13 Jun 2019
Direct dependencies7
Transitive dependenciesNot calculated

README

Current package documentation

General Wanchain utility module with helper functions for the Wanchain blockchain.

The 0xcert Framework is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the official documentation for more details.

This module is one of the bricks of the 0xcert Framework. It's written with TypeScript and it's actively maintained. The source code is available on GitHub where you can also find our issue tracker.

Wanchain Utilities

This module wraps several useful Wanchain functions which will be useful through the 0xcert Framework. Currently supported are these functions and classes from ethers.js:

ABI coder

This converts the value to and from the packed Ethereum ABI encoding.

  • encodeParameters(types: any, values: Array<any>): string
  • decodeParameters(types: any, data: any): any

Encoding example:

import { decodeParameters, encodeParameters } from '0xcert/ethereum-utils/abi';

const types = ['tuple(uint256, uint256[])'];
const values = [[ 42, [ 45 ] ]];
const encodedValues = encodeParameters(types, values);

Decoding example:

import { decodeParameters, encodeParameters } from '0xcert/ethereum-utils/abi';

const types = ['tuple(uint256, uint256[])'];
const encoded = '0x' +
  '0000000000000000000000000000000000000000000000000000000000000020' +
  '000000000000000000000000000000000000000000000000000000000000002a' +
  '0000000000000000000000000000000000000000000000000000000000000040' +
  '0000000000000000000000000000000000000000000000000000000000000001' +
  '000000000000000000000000000000000000000000000000000000000000002d';
const values = decodeParameters(types, values);

Big numbers

Here is a basic example adapted from the ethers.js documentation.

import { bigNumberify } from '0xcert/ethereum-utils/big-number';

let gasPriceWei = bigNumberify("20902747399");
let gasLimit = bigNumberify(3000000);

let maxCostWei = gasPriceWei.mul(gasLimit)
console.log("Max Cost: " + maxCostWei.toString());
// "Max Cost: 62708242197000000"

console.log("Number: " + maxCostWei.toNumber());
// throws an Error, the value is too large for JavaScript to handle safely

Address normalization

The ethers.js address normalization function implements EIP-55 Mixed-case checksum address encoding.

import { getAddress } from '0xcert/ethereum-utils/normalize-address';

let zxcTokenAddress = '0x83e2be8d114f9661221384b3a50d24b96a5653f5';
let zxcTokenAddressNormalized = normalizeAddress(zxcToenAddress);
// 0x83e2BE8d114F9661221384B3a50d24B96a5653F5

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 7

Native requirements
7 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
4.0.0-beta.1runtime
@0xcert/ethereum-utils
Environment
{
  "local_name": "@0xcert/ethereum-utils",
  "alias": false,
  "peer_metadata": null
}
1.7.3runtime
@hayspec/cli
Environment
{
  "local_name": "@hayspec/cli",
  "alias": false,
  "peer_metadata": null
}
^0.8.3development
@hayspec/spec
Environment
{
  "local_name": "@hayspec/spec",
  "alias": false,
  "peer_metadata": null
}
^0.8.3development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^7.0.1development
tslint
Environment
{
  "local_name": "tslint",
  "alias": false,
  "peer_metadata": null
}
^5.12.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^3.1.1development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-5z82kaJfYngWFmP9wkcrz6pL2/4nz4lxubeRl/pmePz6CdWHFSSZKsaGSG4FxS388QDSklEmTVlVz43pTpP0Ag==",
  "shasum": "0017d93b9eb56bb4dffb19a7e145220c19a95e2a",
  "tarball": "https://registry.npmjs.org/@0xcert/wanchain-utils/-/wanchain-utils-1.7.3.tgz",
  "fileCount": 22,
  "unpackedSize": 22352,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdAkdQCRA9TVsSAnZWagAAoFIP/0AV7n3kYwNMq6rj2C3R\nZM5dV8yZh79ZnxJDlPFZl3kCVmgNkhJb36MehO1RFPcwK55l3tE1NRggCMqj\npmKrLLqfq2KmGq2iUsi7/HW33LarRw/2EONYXV9/vnxaqHvpOfxSfAougtJB\nXgRzSytKSDVTfspTHbjQp6vTGqilSLGfwcXW09KHyRePpAaHIZH8Z5BgXKrk\nRAH7nm2HC4bpWDrt+VgGBZ1k2PYukbCgqVnLtUnE0YMfOFAcQjXesrzmR9Bs\nlkiKIpsXBRG23+CwZYXmF6hEf04DpAPunuY7O8Lcp3BDMiS7ET0AC4iGfU4O\ndoLM80hkII1wem1HydmW5HJcwAvdcI1v7rZzHezNQItewbPtINmFGPzFGehc\nlM1rCsZitk+PhOLLaFNidqqzmHKiI1DOTcTFyDJoUVUjIg2BtFR1+ln7fwKn\nEj5s5TM0n2uzCrR+ptCNLTPr5YFH2CQ2UZif6Kka4RAfjAvw2aUxx86LWiOb\nIrFJJ17rRWqrS0A5p1HT4TkJQvLberPJh92InLTWCE+yniYzDqofNx7xJY8C\nrdhLg0wZQSdl1rr5vF2MYqqy9iEHnI+xvTICZjw1AhLCgj/3UbA0vBvoTx0e\nZ/Qm20GuBS6qzc/kj435BqckFhb8dYYmxt73dQlIIiPnL9xwD71L5htK1Duo\nPx2n\r\n=qWWM\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQClUXH6FozpQWBGD16qqCqBkhVMaaiG9KLc9vBjamWhwAIgD53rHpVcpUWeuFCPGUlhmW0HkAsrqfEdFVNhKjmJWw0="
    }
  ]
}

Repository

PENDING
0xcert/framework

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:49 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:44686548a5ee89f3fef0f49806e2f56cc05243d773faa4eabf8d86d01f0ca426

Other collected versions

2.1.115 Mar2.1.014 Jan2.0.312 Aug2.0.24 May2.0.16 Mar2.0.1-beta05 MarView all collected versions →