Nocturnal Pumpkin Maelstrom

is-ethereum-address

1.0.2 • Public • Published

is-ethereum-address

Just a simple utility for lightweight validation an Ethereum address.

This is a standalone implementation of web3.isEthereumAddress with limited dependencies and an ES5 build. The keccak package depended on will use libkeccak for performance if the platform in question is supported; if not, a pure Javascript implementation is used.

Usage

const isEthereumAddress = require('is-ethereum-address');
if (isEthereumAddress('0xa57e3290d0b7cb2748ed410c19c1d58f7f192bc0')) {
  console.log('This is a valid Ethereum address, prefixed with a 0x');
}
 
if (isEthereumAddress('a57e3290d0b7cb2748ed410c19c1d58f7f192bc0')) {
  console.log('This is a valid Ethereum address with no prefix');
}
 
if (isEthereumAddress('0xA57E3290D0b7cb2748Ed410C19c1D58F7F192bc0')) {
  console.log(
    'This is a valid Ethereum address, with EIP 55-style checksumming'
  );
}

The library validates capitalization per EIP 55 if there is mixed capitalization provided.

install

npm i is-ethereum-address

Downloadsweekly downloads

57

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability