Catalog npm
Back to packageRELEASE DETAILS

2.0.0-alpha17

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
Published14 Jan 2020
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.40runtime
@hayspec/cli
Environment
{
  "local_name": "@hayspec/cli",
  "alias": false,
  "peer_metadata": null
}
0.9.0development
@hayspec/spec
Environment
{
  "local_name": "@hayspec/spec",
  "alias": false,
  "peer_metadata": null
}
0.9.0development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
8.4.1development
tslint
Environment
{
  "local_name": "tslint",
  "alias": false,
  "peer_metadata": null
}
5.20.0development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
3.6.3development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-Otkd4VYsc/BsmhzHP3ehYH23MfQj+FgDuRXHwXUUTdYVXuy+4PlB/tUUsOc7XklakZ2UWs0BTcHeq4eFlJ21VA==",
  "shasum": "b474016d4c39b98a4bbb72cc0b4a8f83bd8574b8",
  "tarball": "https://registry.npmjs.org/@0xcert/ethereum-utils/-/ethereum-utils-2.0.0-alpha17.tgz",
  "fileCount": 65,
  "unpackedSize": 48845,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHdC4CRA9TVsSAnZWagAAjmcP/0wpYWMRB/og8vd3aRST\nAWTPnPAkOF8g+1AOyIece0Tyvj3w7V4/4kdnE0lNAU/iU+GPATO2GnjY399i\nqUfCruMBjS1a7Ag/4/XeaLPquJCG/81Wtwj8MOfaIp/RbuRUxBDCtriE46wu\nce4EJG+SKU0O51Aq+/rgnfc8r88TgYRmjrUbPGvc+gDVtMF5GjzqN2aj/Mrp\nMxGB2+4iHYvqWKBrLEvPMWO13yZ/tw8g84Q4ZLjIghMh4guB9GW9RfRpOtdZ\nPCNc1Uc3+a9V/Emu3+rFwzWr5P0CSU/PwlLRSe+wgv7zhu7r+/Mireu3mZu1\nWg0OFxSWPtW7C2wJf2dqFjaLHBgku5BlGVhBZTje3l65obUVOlCTOJkm9z3z\nVxnz5WezjXuBiAzl+zol8vynzx0LYdtBcjzTQ6KJLL2JjKnipHRdwD5GZB+C\n9mfPGyKWAk7GeH0N2hQAykMn2QvNVKZ4uJiRgy+j+0yExD87oy3xadgJSdkh\nQwoUWQVZ0WBsYwCJgqpQ+uko6zyfUbZMTbyeX/UCpFCGYqy936igu5biNnOw\nHhRg/MKxLUn8fjnc+R5O94lQ8CweFrFXcRnX9VALQn3DKIox/Aez3yhNSPSX\nkxPMlBTBalfVZkOlBh0KvLEkeObtxwdqLrIWJlCBJ4kfh4ZSbvj4l0/t/XA7\no0hS\r\n=Z3cP\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIEhNN+nAgdjaKmimLkveWeezpMHrDpRc2d6w1Kr+hG4NAiEAu7HQxcwMSBV22KJRh1C+pd3tylG0LXIaRJ1GNTa6Wk8="
    }
  ]
}

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:7329726458af2a5454ccbaaaa996ad4bc749c2f773969754d779a7d4b42e0b3b

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 →