@403name/ether-js
v1.0.2
Published
Lightweight Ethereum utility library — format ether, parse units, validate addresses, EIP-55 checksums, keccak256 hashing
Maintainers
Readme
ether-js
Lightweight Ethereum utility library for Node.js and browser.
Zero dependencies. Includes a pure-JS keccak256 implementation — no @noble/hashes, no ethers, nothing extra.
Features
- formatEther — Convert wei to human-readable ETH strings
- parseEther — Parse ETH strings to wei (BigInt)
- isAddress — Validate Ethereum addresses
- toChecksumAddress — Convert to EIP-55 checksummed address
- keccak256 — Compute keccak256 hash (pure JS, no deps)
- Zero dependencies — Lightweight, tree-shakeable
- TypeScript — Full type definitions included
Installation
npm install ether-jsUsage
const { formatEther, parseEther, isAddress } = require('ether-js');
// Convert wei to ETH
console.log(formatEther(1000000000000000000n)); // "1.0"
// Parse ETH to wei
console.log(parseEther('1.5')); // 1500000000000000000n
// Validate address
console.log(isAddress('0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18')); // trueAPI
formatEther(wei: bigint | string | number): string
Convert wei to ether, with 18 decimal places.
parseEther(eth: string | number): bigint
Convert ether string to wei as BigInt.
isAddress(address: string): boolean
Returns true if the string is a valid Ethereum address.
toChecksumAddress(address: string): string | null
Returns EIP-55 checksummed address or null if invalid.
keccak256(data: string | Uint8Array): string
Compute keccak256 hash of input data. Accepts hex strings (with or without 0x prefix), plain strings (UTF-8 encoded), and Uint8Array.
License
MIT
