๐ชถ Essential Eth ๐ชถ
An alternative for ethers & web3 that's 10x smaller
Why you should replace Ethers.js and web3
Bundle Size Comparison (ESM, minified)
Measured with esbuild. Smaller is better.
| What you import |
essential-eth@1.1.1 |
ethers@6.17.0 |
viem@2.56.8 |
web3@4.16.0 |
ox@1.8.1 |
| Full library |
43.1 kB ๐ |
398.2 kB |
385.7 kB |
495.8 kB |
732.4 kB |
| Provider (getBalance, getBlock, etc) |
30.8 kB |
264.1 kB |
301.6 kB |
454.5 kB |
7.3 kB ๐ |
| Contract (read-only calls) |
24.9 kB ๐ |
86.6 kB |
185.1 kB |
265.0 kB |
52.3 kB |
| Conversions (wei, gwei, ether) |
1.2 kB ๐ |
10.4 kB |
2.0 kB |
454.5 kB |
3.4 kB |
essential-eth is 8x smaller than the nearest alternative for full-library usage.
- ๐๏ธ tiny
- ๐ Strongly written TypeScript
- ๐งช Matches both
ethers and web3
- โก๏ธ Near-identical API to
ethers
- โก๏ธ Similar but improved API to
web3
- ๐ Works for all EVM chains
- ๐ Ethereum
- ๐ฃ Polygon
- ๐ด Optimism
- ๐ต Arbitrum
- Many more
- ๐งช Strongly tested
- ๐ฒ Tree-shaking and no side-effects
- ๐ All common JS versions (CommonJS, ESM, & UMD)
- โ
Node 24, 22, 20, & 18
- โ
Web
Who Is This For?
Essential-eth is built for developers where size and speed matter. Check out dedicated guides for your use case:
Table of Contents
Click to expand
Install
npm install --save essential-eth # TypeScript included
# or yarn
yarn add essential-eth # TypeScript included
Browsers:
<!-- index.html -->
<script src="https://unpkg.com/essential-eth@1.1.1"></script>
๐ Utils
import { etherToWei } from 'essential-eth';
// or in a non-import environment
const { etherToWei } = require('essential-eth');
arrayify(value: number | bigint | BytesLike | Hexable, options: DataOptions): Uint8Array
View Example
import { arrayify } from 'essential-eth';
arrayify(1);
// Uint8Array(1) [ 1 ]
arrayify(0x1234);
// Uint8Array(2) [ 18, 52 ]
arrayify('0x1', { hexPad: 'right' });
// Uint8Array(1) [ 16 ]
computeAddress(key: string): string
View Example
import { computeAddress } from 'essential-eth';
computeAddress('0x0458eb591f407aef12936bd2989ca699cf5061de9c4964dd6eb6005fd8f580c407434447e813969a1be6e9954b002cad84dfc67a69e032b273e4695e7d0db2d952'); // public key
// '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
computeAddress('0x2f2c419acf4a1da8c1ebea75bb3fcfbd3ec2aa3bf0162901ccdc2f38b8f92427'); // private key
// '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
computePublicKey(privKey: BytesLike): string
View Example
import { computePublicKey } from 'essential-eth';
computePublicKey('0xb27cc8dea0177d910110e8d3ec5480d56c723abf433529f4063f261ffdb9297c');
// '0x045cd0032015eecfde49f82f4e149d804e8ac6e3a0bface32e37c72a71ceac864fe84da7e8df84342f7b11dfb753c4d158f636142b46b29cf7f0f171ae0aa4fb87'
computePublicKey([50,102,50,99,52,49,57,97,99,102,52,97,49,100,97,56,99,49,101,98,101,97,55,53,98,98,51,102,99,102,98,100]);
// '0x04a9cea77eca949df84f661cee153426fb51f2294b9364b4fac240df57360b9b0ac9c99e4d7966491ab4c81f8c82e0cd24ec5759832ad4ab736d22c7d90b806ee8'
concat(arrayOfBytesLike: Array<BytesLikeWithNumber>): Uint8Array
View Example
import { concat } from 'essential-eth';
concat([0, 1]);
// Uint8Array(2) [ 0, 1 ]
decodeBytes32String(bytes32: string): string
View Example
import { decodeBytes32String } from 'essential-eth';
decodeBytes32String('0x657373656e7469616c2d657468000000000000000000000000000000000000')
// 'essential-eth'
decodeEventLog(abi: JSONABI, log: undefined): undefined
View Example
import { decodeEventLog } from 'essential-eth';
const result = decodeEventLog(erc20ABI, {
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
'0x000000000000000000000000abc0000000000000000000000000000000000001',
'0x000000000000000000000000abc0000000000000000000000000000000000002',
],
data: '0x0000000000000000000000000000000000000000000000000000000000000064',
});
// { eventName: 'Transfer', args: { from: '0xABC0...0001', to: '0xaBc0...0002', value: 100n } }
decodeFunctionResult(abi: JSONABI, functionName: string, data: string): any
View Example
import { decodeFunctionResult } from 'essential-eth';
import { decodeFunctionResult } from 'essential-eth';
const abi = [
{
name: 'balanceOf',
type: 'function',
inputs: [{ name: 'owner', type: 'address' }],
outputs: [{ name: 'balance', type: 'uint256' }],
},
];
const result = decodeFunctionResult(abi, 'balanceOf', '0x000...0001');
// result === 1n
encodeBytes32String(text: string): string
View Example
import { encodeBytes32String } from 'essential-eth';
encodeBytes32String('essential-eth')
// '0x657373656e7469616c2d657468000000000000000000000000000000000000'
encodeFunctionData(abi: JSONABI, functionName: string, args?: undefined): string
View Example
import { encodeFunctionData } from 'essential-eth';
import { encodeFunctionData } from 'essential-eth';
const abi = [
{
name: 'balanceOf',
type: 'function',
inputs: [{ name: 'owner', type: 'address' }],
outputs: [{ name: 'balance', type: 'uint256' }],
},
];
const data = encodeFunctionData(abi, 'balanceOf', [
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
]);
etherToGwei(etherQuantity: string | number | bigint): bigint
View Example
import { etherToGwei } from 'essential-eth';
etherToGwei('1000').toString()
// '1000000000000'
etherToGwei(1000).toString()
// '1000000000000'