Catalog npm
Back to packageRELEASE DETAILS

1.5.1

npm

@0xcert/ethereum-utils

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

0xcertassetblockchaincurrencyerc-20erc-721ethereumframeworkfungiblejavascriptlibrariesnodejsnon-fungiblenpmnuxtjsprotocol
All keywords (32)
smart-contracttokentypescriptvaluevaluesvuejszxccontractcontractsethsmartsmart-contractstokensutilitiesutilityutils
Published6 May 2019
Direct dependencies6
Transitive dependenciesNot calculated

README

Current package documentation

General Ethereum utility module with helper functions for the Ethereum 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.

Ethereum Utilities

This module wraps several useful Ethereum 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 umbers

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 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
4.0.0-beta.1runtime
@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-DCnGtXQXpWnuGXnj0FPyz5RNqX9QU5JjhciMZo727HqHFSKELSaaj7UBtnbnrJs0i8HeOCKeeuc+eSIzGNI0TA==",
  "shasum": "65b3a62dc83b9a723f861b55a0d8cea6c14d4d9e",
  "tarball": "https://registry.npmjs.org/@0xcert/ethereum-utils/-/ethereum-utils-1.5.1.tgz",
  "fileCount": 42,
  "unpackedSize": 32908,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc0FvbCRA9TVsSAnZWagAAFEkP/iVT/O8CccCT1aN7G6SY\nk7e95fxtowrjetScHcLJ6ZehLx4KuDgldsGNcrQdmSmhFU9OBQzLQW2avn9N\n1lo+bIjDU121ECfhRZWuAoz803EWy/M/bXk3Ck28zSJY362LOJuskNaXBpO2\nuNs3+cMFZVMdRcnMW85tcUpjMlaaP9bKo1RWkRuxvjS96GR8zIdJL1kzzQuZ\nfEewfclvO69ENFkXY/NleL36BNifsBmSbcorpwjVQTDkHee7OvVahfGv3QdH\nPIxxR7KhRcO7RAJFKs5rrd31trdC4/tbviW5GAYpv410e+aGf3nVAIhhBZhU\nwGTaOqOV7yKYfFu4Vy69pQCfJGsbF7HTpvZexXApn/zi7YkyZ7GWHUmfV61o\nYiTZ1gEA52vV7wNtGSDZ8osPlMey1nqoNRivWOqkDa4FZ4eVpw0cGgip69iA\nMAB0eschHEub9UkZSlY4BqqIULOawDZh+WThMDM5tD+T16DzwpnLjfm5qA2p\npQecirX4B8RFVnBY16Q3evj04Ya2EczHo8D4vJtXNbC/v7A5Ky/pw6gMyhOF\nrFFiPwLhuokaycSz3oPEVCr75z3Kg8FJQlygHP6qbQPjAC5C/vHABY5Ig/TQ\n/5Y8HEOOQXd9wKXFSkd3aKNtYWVXtj1PG7yU0GcbmzBYPNOro6htvM6umWpY\nwsID\r\n=lLHb\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCJDFNptPoVOsjqVzPy2en9iDMx9qdXeCIn4rgZnEwmeQIhALfmS73VEWpavAMn9PXLhl/q2fzyzh5OUwHJM56s0RLD"
    }
  ]
}

Repository

PENDING
0xcert/ethereum-utils

Shared repository data · GitHub

License detected in repository
Not collected

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:48 UTC

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

Record identity

package_version:cf3c2fb04f9e449964297f8eaae43bc6c91c5546dc90613eaf51dd6c7c024d89

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 →