Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethereumjs/util

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/util

A collection of utility functions for Ethereum

  • 9.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
657K
increased by5.54%
Maintainers
4
Weekly downloads
 
Created

What is @ethereumjs/util?

@ethereumjs/util is a utility library for Ethereum-related operations. It provides a wide range of utility functions for handling Ethereum addresses, private keys, public keys, signatures, and other cryptographic operations. This package is essential for developers working on Ethereum-based applications, as it simplifies many common tasks.

What are @ethereumjs/util's main functionalities?

Address Utilities

This feature allows you to convert an Ethereum address to its checksummed version, which includes mixed-case letters to help prevent errors.

const { toChecksumAddress } = require('@ethereumjs/util');
const address = '0x32Be343B94f860124dC4fEe278FDCBD38C102D88';
const checksumAddress = toChecksumAddress(address);
console.log(checksumAddress); // '0x32Be343B94f860124dC4fEe278FDCBD38C102D88'

Private Key Utilities

This feature allows you to derive an Ethereum address from a given private key.

const { privateToAddress } = require('@ethereumjs/util');
const privateKey = Buffer.from('c87509a1c067bbde78beb793e6fa1b2b4a5c4c9c3c8e3b3a3b3a3b3a3b3a3b3a', 'hex');
const address = privateToAddress(privateKey);
console.log(address.toString('hex')); // '0x32Be343B94f860124dC4fEe278FDCBD38C102D88'

Signature Utilities

This feature allows you to sign a message hash with a private key and convert the signature to RPC format.

const { ecsign, toRpcSig } = require('@ethereumjs/util');
const msgHash = Buffer.from('5c6ffbdd40d9556b73a21e63c3e0e904e4e1a8a0', 'hex');
const privateKey = Buffer.from('c87509a1c067bbde78beb793e6fa1b2b4a5c4c9c3c8e3b3a3b3a3b3a3b3a3b3a', 'hex');
const sig = ecsign(msgHash, privateKey);
const rpcSig = toRpcSig(sig.v, sig.r, sig.s);
console.log(rpcSig); // '0x...' (signature in RPC format)

Other packages similar to @ethereumjs/util

Keywords

FAQs

Package last updated on 15 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc