Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
ethjs-util
Advanced tools
The ethjs-util package provides a collection of utility functions for Ethereum-related operations. These utilities include functions for handling hex strings, checking types, and manipulating buffers, among others.
Hex String Conversion
This feature allows you to convert a buffer to a hex string. The code sample demonstrates converting the string 'hello' into its hex representation.
const ethUtil = require('ethjs-util');
const hexString = ethUtil.bufferToHex(Buffer.from('hello', 'utf8'));
console.log(hexString); // '0x68656c6c6f'
Type Checking
This feature provides functions to check if a given string is a valid hex string. The code sample checks if '0x68656c6c6f' is a hex string.
const ethUtil = require('ethjs-util');
const isHex = ethUtil.isHexString('0x68656c6c6f');
console.log(isHex); // true
Buffer Manipulation
This feature includes functions for manipulating buffers, such as setting their length. The code sample demonstrates padding a buffer to a specified length.
const ethUtil = require('ethjs-util');
const buffer = ethUtil.setLengthLeft(Buffer.from('1234', 'utf8'), 10);
console.log(buffer); // <Buffer 00 00 00 00 00 00 31 32 33 34>
The ethereumjs-util package offers a comprehensive set of utility functions for Ethereum, similar to ethjs-util. It includes additional features like keccak256 hashing and RLP encoding/decoding, making it more versatile for Ethereum development.
The web3-utils package is part of the Web3.js library and provides utility functions for Ethereum dApp development. It includes functions for hex string manipulation, type checking, and more, similar to ethjs-util, but is more tightly integrated with the Web3.js ecosystem.
The ethers-utils package is part of the ethers.js library and offers a wide range of utility functions for Ethereum. It provides similar functionalities to ethjs-util, such as hex string conversion and type checking, but also includes additional features like ABI encoding/decoding and ENS name resolution.
A simple set of Ethereum JS utilities such as toBuffer
and isHexPrefixed
.
npm install --save ethjs-util
const util = require('ethjs-util');
const value = util.intToBuffer(38272);
// returns <Buffer ...>
A simple set of Ethereum JS utilties, mainly for frontend dApps.
arrayContainsArray <Function (Array, Array) : (Boolean)>
getBinarySize <Function (String) : (Number)>
toBuffer <Function (String) : (Buffer)>
intToBuffer <Function (Number) : (Buffer)>
isHexPrefixed <Function (String) : (Boolean)>
stripHexPrefix <Function (String) : (String)>
padToEven <Function (String) : (String)>
intToHex <Function (Number) : (String)>
Please help better the ecosystem by submitting issues and pull requests to default. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard and the unix philosophy.
You'll find more detailed information on using ethjs-util
and tailoring it to your needs in our guides:
ethjs-util
and writing your own code and coverage.There is always a lot of work to do, and will have many rules to maintain. So please help out in any way that you can:
ethjs-util
better, and pull requests to show us how your idea works.Please consult our Code of Conduct docs before helping out.
We communicate via issues and pull requests.
This project is licensed under the MIT license, Copyright (c) 2016 Nick Dodson. For more information see LICENSE.md.
The MIT License
Copyright (c) 2016 Nick Dodson. nickdodson.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
0.1.1 -- less dependencies
FAQs
A simple set of Ethereum JS utilties.
The npm package ethjs-util receives a total of 374,952 weekly downloads. As such, ethjs-util popularity was classified as popular.
We found that ethjs-util demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.