essential-eth 0.13.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/readme.md CHANGED
@@ -20,20 +20,22 @@
20
20
  <img src="https://user-images.githubusercontent.com/3408480/133322814-f3d18424-4ba8-4a37-8cbc-c5e6828354a3.png" title="Import size comparison" width="900"/>
21
21
  </p>
22
22
 
23
+
23
24
  <!-- BUNDLE-SIZE-TABLE:START -->
24
25
 
25
26
  ### Bundle Size Comparison (ESM, minified)
26
27
 
27
28
  Measured with esbuild. Smaller is better.
28
29
 
29
- | What you import | essential-eth@0.13.0 | ethers@6.16.0 | viem@2.45.1 |
30
- | ---------------------------------------- | :------------------: | :-----------: | :-----------: |
31
- | **Full library** | **47.0 kB** 🏆 | 394.0 kB | 384.6 kB |
32
- | **Provider** (getBalance, getBlock, etc) | **37.4 kB** 🏆 | 260.0 kB | 305.7 kB |
33
- | **Contract** (read-only calls) | **33.2 kB** 🏆 | 86.6 kB | 179.8 kB |
34
- | **Conversions** (wei, gwei, ether) | 9.2 kB | 10.4 kB | **2.7 kB** 🏆 |
30
+ | What you import | essential-eth@1.1.0 | ethers@6.16.0 | viem@2.45.1 | web3@4.16.0 | ox@0.12.0 |
31
+ | ---------------------------------------- | :-----------------: | :-----------: | :---------: | :---------: | :------------: |
32
+ | **Full library** | **43.1 kB** 🏆 | 394.0 kB | 348.3 kB | 495.8 kB | 612.8 kB |
33
+ | **Provider** (getBalance, getBlock, etc) | 30.8 kB | 260.0 kB | 269.5 kB | 454.5 kB | **10.9 kB** 🏆 |
34
+ | **Contract** (read-only calls) | **24.8 kB** 🏆 | 86.6 kB | 179.8 kB | 264.9 kB | 49.9 kB |
35
+ | **Conversions** (wei, gwei, ether) | **1.2 kB** 🏆 | 10.4 kB | 2.7 kB | 454.5 kB | 3.7 kB |
36
+
37
+ essential-eth is **8x smaller** than the nearest alternative for full-library usage.
35
38
 
36
- essential-eth is **8x smaller** than ethers and viem for full-library usage.
37
39
 
38
40
  <!-- BUNDLE-SIZE-TABLE:END -->
39
41
 
@@ -62,62 +64,88 @@ essential-eth is **8x smaller** than ethers and viem for full-library usage.
62
64
 
63
65
  <br/>
64
66
 
67
+ ## Who Is This For?
68
+
69
+ Essential-eth is built for developers where size and speed matter. Check out dedicated guides for your use case:
70
+
71
+ - **[Chrome Extension Developers](https://github.com/dawsbot/essential-eth/blob/master/static/landing/chrome-extensions.md)** — Service worker size budgets are brutal. 39.9 kB vs ethers' 394 kB makes a real difference.
72
+ - **[Serverless & Edge Functions](https://github.com/dawsbot/essential-eth/blob/master/static/landing/serverless.md)** — Cold starts cost money. Get sub-10ms startup instead of 200ms+.
73
+ - **[React Native Apps](https://github.com/dawsbot/essential-eth/blob/master/static/landing/react-native.md)** — Every KB impacts app store download times. Essential-eth adds 12 kB, ethers adds 104 kB.
74
+ - **[Telegram/Discord Bots](https://github.com/dawsbot/essential-eth/blob/master/static/landing/telegram-bots.md)** — Minimal memory footprint, instant response times. 2 MB vs 45 MB for ethers.
75
+
76
+ <br/>
77
+
65
78
  ## Table of Contents
66
79
 
80
+
67
81
  <!-- ⛔️ AUTO-GENERATED-CONTENT:START (TOC:collapse=true&collapseText=Click to expand) -->
68
82
  <details>
69
83
  <summary>Click to expand</summary>
70
84
 
71
85
  - [Why you should replace Ethers.js and web3](#why-you-should-replace-ethersjs-and-web3)
72
86
  - [Bundle Size Comparison (ESM, minified)](#bundle-size-comparison-esm-minified)
87
+ - [Who Is This For?](#who-is-this-for)
73
88
  - [Install](#install)
74
89
  - [🛠 Utils](#-utils)
75
- - [`arrayify`](#arrayify)
76
- - [`computeAddress`](#computeaddress)
77
- - [`computePublicKey`](#computepublickey)
78
- - [`concat`](#concat)
79
- - [`etherToGwei`](#ethertogwei)
80
- - [`etherToWei`](#ethertowei)
81
- - [`gweiToEther`](#gweitoether)
82
- - [`hashMessage`](#hashmessage)
83
- - [`hexConcat`](#hexconcat)
84
- - [`hexDataLength`](#hexdatalength)
85
- - [`hexDataSlice`](#hexdataslice)
86
- - [`hexStripZeros`](#hexstripzeros)
87
- - [`hexValue`](#hexvalue)
88
- - [`hexZeroPad`](#hexzeropad)
89
- - [`hexlify`](#hexlify)
90
- - [`isAddress`](#isaddress)
91
- - [`isBytes`](#isbytes)
92
- - [`isBytesLike`](#isbyteslike)
93
- - [`isHexString`](#ishexstring)
94
- - [`jsonRpcProvider`](#jsonrpcprovider)
95
- - [`keccak256`](#keccak256)
96
- - [`pack`](#pack)
97
- - [`solidityKeccak256`](#soliditykeccak256)
98
- - [`splitSignature`](#splitsignature)
99
- - [`stripZeros`](#stripzeros)
100
- - [`tinyBig`](#tinybig)
101
- - [`toChecksumAddress`](#tochecksumaddress)
102
- - [`toUtf8Bytes`](#toutf8bytes)
103
- - [`weiToEther`](#weitoether)
104
- - [`zeroPad`](#zeropad)
90
+ - [`arrayify`](#arrayify)
91
+ - [`computeAddress`](#computeaddress)
92
+ - [`computePublicKey`](#computepublickey)
93
+ - [`concat`](#concat)
94
+ - [`decodeBytes32String`](#decodebytes32string)
95
+ - [`decodeEventLog`](#decodeeventlog)
96
+ - [`decodeFunctionResult`](#decodefunctionresult)
97
+ - [`encodeBytes32String`](#encodebytes32string)
98
+ - [`encodeFunctionData`](#encodefunctiondata)
99
+ - [`etherToGwei`](#ethertogwei)
100
+ - [`etherToWei`](#ethertowei)
101
+ - [`formatUnits`](#formatunits)
102
+ - [`getAddress`](#getaddress)
103
+ - [`getEventSignature`](#geteventsignature)
104
+ - [`getEventTopic`](#geteventtopic)
105
+ - [`gweiToEther`](#gweitoether)
106
+ - [`hashMessage`](#hashmessage)
107
+ - [`hexConcat`](#hexconcat)
108
+ - [`hexDataLength`](#hexdatalength)
109
+ - [`hexDataSlice`](#hexdataslice)
110
+ - [`hexStripZeros`](#hexstripzeros)
111
+ - [`hexValue`](#hexvalue)
112
+ - [`hexZeroPad`](#hexzeropad)
113
+ - [`hexlify`](#hexlify)
114
+ - [`id`](#id)
115
+ - [`isAddress`](#isaddress)
116
+ - [`isBytes`](#isbytes)
117
+ - [`isBytesLike`](#isbyteslike)
118
+ - [`isHexString`](#ishexstring)
119
+ - [`jsonRpcProvider`](#jsonrpcprovider)
120
+ - [`keccak256`](#keccak256)
121
+ - [`namehash`](#namehash)
122
+ - [`pack`](#pack)
123
+ - [`parseUnits`](#parseunits)
124
+ - [`solidityKeccak256`](#soliditykeccak256)
125
+ - [`splitSignature`](#splitsignature)
126
+ - [`stripZeros`](#stripzeros)
127
+ - [`toChecksumAddress`](#tochecksumaddress)
128
+ - [`toUtf8Bytes`](#toutf8bytes)
129
+ - [`toUtf8String`](#toutf8string)
130
+ - [`weiToEther`](#weitoether)
131
+ - [`zeroPad`](#zeropad)
105
132
  - [Providers](#providers)
106
- - [`call`](#call)
107
- - [`estimateGas`](#estimategas)
108
- - [`getBalance`](#getbalance)
109
- - [`getBlock`](#getblock)
110
- - [`getBlockNumber`](#getblocknumber)
111
- - [`getCode`](#getcode)
112
- - [`getFeeData`](#getfeedata)
113
- - [`getGasPrice`](#getgasprice)
114
- - [`getLogs`](#getlogs)
115
- - [`getNetwork`](#getnetwork)
116
- - [`getTransaction`](#gettransaction)
117
- - [`getTransactionCount`](#gettransactioncount)
118
- - [`getTransactionReceipt`](#gettransactionreceipt)
133
+ - [`call`](#call)
134
+ - [`estimateGas`](#estimategas)
135
+ - [`getBalance`](#getbalance)
136
+ - [`getBlock`](#getblock)
137
+ - [`getBlockNumber`](#getblocknumber)
138
+ - [`getCode`](#getcode)
139
+ - [`getFeeData`](#getfeedata)
140
+ - [`getGasPrice`](#getgasprice)
141
+ - [`getLogs`](#getlogs)
142
+ - [`getNetwork`](#getnetwork)
143
+ - [`getTransaction`](#gettransaction)
144
+ - [`getTransactionCount`](#gettransactioncount)
145
+ - [`getTransactionReceipt`](#gettransactionreceipt)
146
+ - [`resolveName`](#resolvename)
119
147
  - [Contract](#contract)
120
- - [`contractFunctionName(args)`](#contractfunctionnameargs)
148
+ - [`contractFunctionName(args)`](#contractfunctionnameargs)
121
149
  - [More Info](#more-info)
122
150
  - [Identical vs Similar vs Dissimilar {&#035;isd}](#identical-vs-similar-vs-dissimilar-isd)
123
151
  - [Miscellaneous](#miscellaneous)
@@ -140,12 +168,15 @@ yarn add essential-eth # TypeScript included
140
168
 
141
169
  Browsers:
142
170
 
171
+
143
172
  <!-- ⛔️ AUTO-GENERATED-CONTENT:START (UNPKG_SCRIPT_TAG) -->
144
173
 
145
174
  ```html
175
+
146
176
  <!-- index.html -->
147
- <script src="https://unpkg.com/essential-eth@0.13.0"></script>
177
+ <script src="https://unpkg.com/essential-eth@1.1.0"></script>
148
178
  ```
179
+
149
180
 
150
181
  <!-- ⛔️ AUTO-GENERATED-CONTENT:END (UNPKG_SCRIPT_TAG) -->
151
182
 
@@ -160,33 +191,29 @@ import { etherToWei } from 'essential-eth';
160
191
  const { etherToWei } = require('essential-eth');
161
192
  ```
162
193
 
163
- <!-- ⛔️ AUTO-GENERATED-CONTENT:START (FUNCTIONS) -->
164
194
 
195
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:START (FUNCTIONS) -->
165
196
  #### [`arrayify`](https://eeth.dev/docs/api/modules#arrayify)
166
-
167
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+arrayify+}])
168
-
169
- ```typescript
170
- arrayify(value: number | BytesLike | Hexable, options: DataOptions): Uint8Array
171
- ```
172
-
197
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+arrayify+}])
198
+ ```typescript
199
+ arrayify(value: number | bigint | BytesLike | Hexable, options: DataOptions): Uint8Array
200
+ ```
201
+
173
202
  <details>
174
203
  <summary>View Example</summary>
175
204
 
176
- ```js
177
- import { arrayify } from 'essential-eth';
178
- ```
205
+ ```js
206
+ import { arrayify } from 'essential-eth';
207
+ ```
179
208
 
180
- ```javascript
209
+ ```javascript
181
210
  arrayify(1);
182
211
  // Uint8Array(1) [ 1 ]
183
212
  ```
184
-
185
213
  ```javascript
186
214
  arrayify(0x1234);
187
215
  // Uint8Array(2) [ 18, 52 ]
188
216
  ```
189
-
190
217
  ```javascript
191
218
  arrayify('0x1', { hexPad: 'right' });
192
219
  // Uint8Array(1) [ 16 ]
@@ -197,31 +224,24 @@ arrayify('0x1', { hexPad: 'right' });
197
224
  <br/>
198
225
 
199
226
  #### [`computeAddress`](https://eeth.dev/docs/api/modules#computeaddress)
200
-
201
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+computeAddress+}])
202
-
203
- ```typescript
204
- computeAddress(key: string): string
205
- ```
206
-
227
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+computeAddress+}])
228
+ ```typescript
229
+ computeAddress(key: string): string
230
+ ```
231
+
207
232
  <details>
208
233
  <summary>View Example</summary>
209
234
 
210
- ```js
211
- import { computeAddress } from 'essential-eth';
212
- ```
235
+ ```js
236
+ import { computeAddress } from 'essential-eth';
237
+ ```
213
238
 
214
- ```javascript
215
- computeAddress(
216
- '0x0458eb591f407aef12936bd2989ca699cf5061de9c4964dd6eb6005fd8f580c407434447e813969a1be6e9954b002cad84dfc67a69e032b273e4695e7d0db2d952',
217
- ); // public key
239
+ ```javascript
240
+ computeAddress('0x0458eb591f407aef12936bd2989ca699cf5061de9c4964dd6eb6005fd8f580c407434447e813969a1be6e9954b002cad84dfc67a69e032b273e4695e7d0db2d952'); // public key
218
241
  // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
219
242
  ```
220
-
221
243
  ```javascript
222
- computeAddress(
223
- '0x2f2c419acf4a1da8c1ebea75bb3fcfbd3ec2aa3bf0162901ccdc2f38b8f92427',
224
- ); // private key
244
+ computeAddress('0x2f2c419acf4a1da8c1ebea75bb3fcfbd3ec2aa3bf0162901ccdc2f38b8f92427'); // private key
225
245
  // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
226
246
  ```
227
247
 
@@ -230,32 +250,24 @@ computeAddress(
230
250
  <br/>
231
251
 
232
252
  #### [`computePublicKey`](https://eeth.dev/docs/api/modules#computepublickey)
233
-
234
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+computePublicKey+}])
235
-
236
- ```typescript
237
- computePublicKey(privKey: BytesLike): string
238
- ```
239
-
253
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+computePublicKey+}])
254
+ ```typescript
255
+ computePublicKey(privKey: BytesLike): string
256
+ ```
257
+
240
258
  <details>
241
259
  <summary>View Example</summary>
242
260
 
243
- ```js
244
- import { computePublicKey } from 'essential-eth';
245
- ```
261
+ ```js
262
+ import { computePublicKey } from 'essential-eth';
263
+ ```
246
264
 
247
- ```javascript
248
- computePublicKey(
249
- '0xb27cc8dea0177d910110e8d3ec5480d56c723abf433529f4063f261ffdb9297c',
250
- );
265
+ ```javascript
266
+ computePublicKey('0xb27cc8dea0177d910110e8d3ec5480d56c723abf433529f4063f261ffdb9297c');
251
267
  // '0x045cd0032015eecfde49f82f4e149d804e8ac6e3a0bface32e37c72a71ceac864fe84da7e8df84342f7b11dfb753c4d158f636142b46b29cf7f0f171ae0aa4fb87'
252
268
  ```
253
-
254
269
  ```javascript
255
- computePublicKey([
256
- 50, 102, 50, 99, 52, 49, 57, 97, 99, 102, 52, 97, 49, 100, 97, 56, 99, 49,
257
- 101, 98, 101, 97, 55, 53, 98, 98, 51, 102, 99, 102, 98, 100,
258
- ]);
270
+ 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]);
259
271
  // '0x04a9cea77eca949df84f661cee153426fb51f2294b9364b4fac240df57360b9b0ac9c99e4d7966491ab4c81f8c82e0cd24ec5759832ad4ab736d22c7d90b806ee8'
260
272
  ```
261
273
 
@@ -264,196 +276,407 @@ computePublicKey([
264
276
  <br/>
265
277
 
266
278
  #### [`concat`](https://eeth.dev/docs/api/modules#concat)
279
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+concat+}])
280
+ ```typescript
281
+ concat(arrayOfBytesLike: Array<BytesLikeWithNumber>): Uint8Array
282
+ ```
283
+
284
+ <details>
285
+ <summary>View Example</summary>
267
286
 
268
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+concat+}])
287
+ ```js
288
+ import { concat } from 'essential-eth';
289
+ ```
269
290
 
270
- ```typescript
271
- concat(arrayOfBytesLike: Array<BytesLikeWithNumber>): Uint8Array
291
+ ```javascript
292
+ concat([0, 1]);
293
+ // Uint8Array(2) [ 0, 1 ]
272
294
  ```
273
295
 
296
+ </details>
297
+
298
+ <br/>
299
+
300
+ #### [`decodeBytes32String`](https://eeth.dev/docs/api/modules#decodebytes32string)
301
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+decodeBytes32String+}])
302
+ ```typescript
303
+ decodeBytes32String(bytes32: string): string
304
+ ```
305
+
274
306
  <details>
275
307
  <summary>View Example</summary>
276
308
 
277
- ```js
278
- import { concat } from 'essential-eth';
279
- ```
309
+ ```js
310
+ import { decodeBytes32String } from 'essential-eth';
311
+ ```
280
312
 
281
- ```javascript
282
- concat([0, 1]);
283
- // Uint8Array(2) [ 0, 1 ]
313
+ ```javascript
314
+ decodeBytes32String('0x657373656e7469616c2d657468000000000000000000000000000000000000')
315
+ // 'essential-eth'
284
316
  ```
285
317
 
286
318
  </details>
287
319
 
288
320
  <br/>
289
321
 
290
- #### [`etherToGwei`](https://eeth.dev/docs/api/modules#ethertogwei)
322
+ #### [`decodeEventLog`](https://eeth.dev/docs/api/modules#decodeeventlog)
323
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+decodeEventLog+}])
324
+ ```typescript
325
+ decodeEventLog(abi: JSONABI, log: undefined): undefined
326
+ ```
327
+
328
+ <details>
329
+ <summary>View Example</summary>
291
330
 
292
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+etherToGwei+}])
331
+ ```js
332
+ import { decodeEventLog } from 'essential-eth';
333
+ ```
293
334
 
294
- ```typescript
295
- etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig
335
+ ```javascript
336
+ const result = decodeEventLog(erc20ABI, {
337
+ topics: [
338
+ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
339
+ '0x000000000000000000000000abc0000000000000000000000000000000000001',
340
+ '0x000000000000000000000000abc0000000000000000000000000000000000002',
341
+ ],
342
+ data: '0x0000000000000000000000000000000000000000000000000000000000000064',
343
+ });
344
+ // { eventName: 'Transfer', args: { from: '0xABC0...0001', to: '0xaBc0...0002', value: 100n } }
296
345
  ```
297
346
 
347
+ </details>
348
+
349
+ <br/>
350
+
351
+ #### [`decodeFunctionResult`](https://eeth.dev/docs/api/modules#decodefunctionresult)
352
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+decodeFunctionResult+}])
353
+ ```typescript
354
+ decodeFunctionResult(abi: JSONABI, functionName: string, data: string): any
355
+ ```
356
+
298
357
  <details>
299
358
  <summary>View Example</summary>
300
359
 
301
- ```js
302
- import { etherToGwei } from 'essential-eth';
303
- ```
360
+ ```js
361
+ import { decodeFunctionResult } from 'essential-eth';
362
+ ```
304
363
 
305
- ```javascript
306
- etherToGwei('1000').toString();
307
- // '1000000000000'
308
- etherToGwei(1000).toString();
309
- // '1000000000000'
310
- ```
364
+ ```typescript
365
+ import { decodeFunctionResult } from 'essential-eth';
311
366
 
312
- ```javascript
313
- etherToGwei('1000').toNumber();
314
- // 1000000000000
315
- etherToGwei(1000).toNumber();
316
- // 1000000000000
367
+ const abi = [
368
+ {
369
+ name: 'balanceOf',
370
+ type: 'function',
371
+ inputs: [{ name: 'owner', type: 'address' }],
372
+ outputs: [{ name: 'balance', type: 'uint256' }],
373
+ },
374
+ ];
375
+
376
+ const result = decodeFunctionResult(abi, 'balanceOf', '0x000...0001');
377
+ // result === 1n
317
378
  ```
318
379
 
319
380
  </details>
320
381
 
321
382
  <br/>
322
383
 
323
- #### [`etherToWei`](https://eeth.dev/docs/api/modules#ethertowei)
384
+ #### [`encodeBytes32String`](https://eeth.dev/docs/api/modules#encodebytes32string)
385
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+encodeBytes32String+}])
386
+ ```typescript
387
+ encodeBytes32String(text: string): string
388
+ ```
389
+
390
+ <details>
391
+ <summary>View Example</summary>
324
392
 
325
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+etherToWei+}])
393
+ ```js
394
+ import { encodeBytes32String } from 'essential-eth';
395
+ ```
326
396
 
327
- ```typescript
328
- etherToWei(etherQuantity: string | number | TinyBig | Big): TinyBig
397
+ ```javascript
398
+ encodeBytes32String('essential-eth')
399
+ // '0x657373656e7469616c2d657468000000000000000000000000000000000000'
329
400
  ```
330
401
 
402
+ </details>
403
+
404
+ <br/>
405
+
406
+ #### [`encodeFunctionData`](https://eeth.dev/docs/api/modules#encodefunctiondata)
407
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+encodeFunctionData+}])
408
+ ```typescript
409
+ encodeFunctionData(abi: JSONABI, functionName: string, args?: undefined): string
410
+ ```
411
+
331
412
  <details>
332
413
  <summary>View Example</summary>
333
414
 
334
- ```js
335
- import { etherToWei } from 'essential-eth';
336
- ```
415
+ ```js
416
+ import { encodeFunctionData } from 'essential-eth';
417
+ ```
337
418
 
338
- ```javascript
339
- etherToWei('1000').toString();
340
- // '1000000000000000000000'
341
- etherToWei(1000).toString();
342
- // '1000000000000000000000'
343
- ```
419
+ ```typescript
420
+ import { encodeFunctionData } from 'essential-eth';
344
421
 
345
- ```javascript
346
- etherToWei('1000').toNumber();
347
- // 1000000000000000000000
348
- etherToWei(1000).toNumber();
349
- // 1000000000000000000000
422
+ const abi = [
423
+ {
424
+ name: 'balanceOf',
425
+ type: 'function',
426
+ inputs: [{ name: 'owner', type: 'address' }],
427
+ outputs: [{ name: 'balance', type: 'uint256' }],
428
+ },
429
+ ];
430
+
431
+ const data = encodeFunctionData(abi, 'balanceOf', [
432
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
433
+ ]);
350
434
  ```
351
435
 
352
436
  </details>
353
437
 
354
438
  <br/>
355
439
 
356
- #### [`gweiToEther`](https://eeth.dev/docs/api/modules#gweitoether)
440
+ #### [`etherToGwei`](https://eeth.dev/docs/api/modules#ethertogwei)
441
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+etherToGwei+}])
442
+ ```typescript
443
+ etherToGwei(etherQuantity: string | number | bigint): bigint
444
+ ```
445
+
446
+ <details>
447
+ <summary>View Example</summary>
357
448
 
358
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+gweiToEther+}])
449
+ ```js
450
+ import { etherToGwei } from 'essential-eth';
451
+ ```
359
452
 
360
- ```typescript
361
- gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig
453
+ ```javascript
454
+ etherToGwei('1000').toString()
455
+ // '1000000000000'
456
+ etherToGwei(1000).toString()
457
+ // '1000000000000'
362
458
  ```
363
459
 
460
+ </details>
461
+
462
+ <br/>
463
+
464
+ #### [`etherToWei`](https://eeth.dev/docs/api/modules#ethertowei)
465
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+etherToWei+}])
466
+ ```typescript
467
+ etherToWei(etherQuantity: string | number | bigint): bigint
468
+ ```
469
+
364
470
  <details>
365
471
  <summary>View Example</summary>
366
472
 
367
- ```js
368
- import { gweiToEther } from 'essential-eth';
473
+ ```js
474
+ import { etherToWei } from 'essential-eth';
475
+ ```
476
+
477
+ ```javascript
478
+ etherToWei('1000').toString()
479
+ // '1000000000000000000000'
480
+ etherToWei(1000).toString()
481
+ // '1000000000000000000000'
369
482
  ```
370
483
 
484
+ </details>
485
+
486
+ <br/>
487
+
488
+ #### [`formatUnits`](https://eeth.dev/docs/api/modules#formatunits)
489
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+formatUnits+}])
490
+ ```typescript
491
+ formatUnits(value: string | number | bigint, decimals?: number): string
492
+ ```
493
+
494
+ <details>
495
+ <summary>View Example</summary>
496
+
497
+ ```js
498
+ import { formatUnits } from 'essential-eth';
499
+ ```
500
+
501
+ ```javascript
502
+ formatUnits(1000000n, 6)
503
+ // '1'
504
+ ```
371
505
  ```javascript
372
- gweiToEther('1000000000000').toString();
373
- // '1000'
374
- gweiToEther(1000000000000).toString();
375
- // '1000'
506
+ formatUnits('1000000000000000000', 18)
507
+ // '1'
376
508
  ```
377
-
378
509
  ```javascript
379
- gweiToEther('1000000000000').toNumber();
380
- // 1000
381
- gweiToEther(1000000000000).toNumber();
382
- // 1000
510
+ formatUnits(1500000n, 6)
511
+ // '1.5'
383
512
  ```
384
513
 
385
514
  </details>
386
515
 
387
516
  <br/>
388
517
 
389
- #### [`hashMessage`](https://eeth.dev/docs/api/modules#hashmessage)
518
+ #### [`getAddress`](https://eeth.dev/docs/api/modules#getaddress)
519
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+getAddress+}])
520
+ ```typescript
521
+ getAddress(address: string): string
522
+ ```
523
+
524
+ <details>
525
+ <summary>View Example</summary>
390
526
 
391
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hashMessage+}])
527
+ ```js
528
+ import { getAddress } from 'essential-eth';
529
+ ```
392
530
 
393
- ```typescript
394
- hashMessage(message: string | Bytes): string
531
+ ```javascript
532
+ getAddress('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
533
+ // '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'
395
534
  ```
396
535
 
536
+ </details>
537
+
538
+ <br/>
539
+
540
+ #### [`getEventSignature`](https://eeth.dev/docs/api/modules#geteventsignature)
541
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+getEventSignature+}])
542
+ ```typescript
543
+ getEventSignature(abi: JSONABI, eventName: string): string
544
+ ```
545
+
397
546
  <details>
398
547
  <summary>View Example</summary>
399
548
 
400
- ```js
401
- import { hashMessage } from 'essential-eth';
402
- ```
549
+ ```js
550
+ import { getEventSignature } from 'essential-eth';
551
+ ```
403
552
 
404
- ```javascript
405
- hashMessage('Hello World');
406
- // '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
553
+ ```javascript
554
+ const abi = [
555
+ {
556
+ type: 'event',
557
+ name: 'Transfer',
558
+ inputs: [
559
+ { name: 'from', type: 'address', indexed: true },
560
+ { name: 'to', type: 'address', indexed: true },
561
+ { name: 'value', type: 'uint256', indexed: false },
562
+ ],
563
+ },
564
+ ];
565
+ getEventSignature(abi, 'Transfer');
566
+ // '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
407
567
  ```
408
568
 
409
569
  </details>
410
570
 
411
571
  <br/>
412
572
 
413
- #### [`hexConcat`](https://eeth.dev/docs/api/modules#hexconcat)
573
+ #### [`getEventTopic`](https://eeth.dev/docs/api/modules#geteventtopic)
574
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+getEventTopic+}])
575
+ ```typescript
576
+ getEventTopic(eventSignature: string): string
577
+ ```
578
+
579
+ <details>
580
+ <summary>View Example</summary>
414
581
 
415
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexConcat+}])
582
+ ```js
583
+ import { getEventTopic } from 'essential-eth';
584
+ ```
416
585
 
417
- ```typescript
418
- hexConcat(items: Array<BytesLike>): string
586
+ ```javascript
587
+ getEventTopic('Transfer(address,address,uint256)');
588
+ // '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
419
589
  ```
420
590
 
591
+ </details>
592
+
593
+ <br/>
594
+
595
+ #### [`gweiToEther`](https://eeth.dev/docs/api/modules#gweitoether)
596
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+gweiToEther+}])
597
+ ```typescript
598
+ gweiToEther(gweiQuantity: string | number | bigint): string
599
+ ```
600
+
421
601
  <details>
422
602
  <summary>View Example</summary>
423
603
 
424
- ```js
425
- import { hexConcat } from 'essential-eth';
426
- ```
604
+ ```js
605
+ import { gweiToEther } from 'essential-eth';
606
+ ```
427
607
 
428
- ```javascript
429
- hexConcat([[2, 4, 0, 1], 9, '0x2934', '0x3947']);
430
- // '0x020400010929343947'
608
+ ```javascript
609
+ gweiToEther('1000000000000')
610
+ // '1000'
611
+ gweiToEther(1000000000000)
612
+ // '1000'
431
613
  ```
432
614
 
433
615
  </details>
434
616
 
435
617
  <br/>
436
618
 
437
- #### [`hexDataLength`](https://eeth.dev/docs/api/modules#hexdatalength)
619
+ #### [`hashMessage`](https://eeth.dev/docs/api/modules#hashmessage)
620
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hashMessage+}])
621
+ ```typescript
622
+ hashMessage(message: string | Bytes): string
623
+ ```
624
+
625
+ <details>
626
+ <summary>View Example</summary>
438
627
 
439
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexDataLength+}])
628
+ ```js
629
+ import { hashMessage } from 'essential-eth';
630
+ ```
440
631
 
441
- ```typescript
442
- hexDataLength(data: BytesLike): undefined
632
+ ```javascript
633
+ hashMessage("Hello World");
634
+ // '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
443
635
  ```
444
636
 
637
+ </details>
638
+
639
+ <br/>
640
+
641
+ #### [`hexConcat`](https://eeth.dev/docs/api/modules#hexconcat)
642
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexConcat+}])
643
+ ```typescript
644
+ hexConcat(items: Array<BytesLike>): string
645
+ ```
646
+
445
647
  <details>
446
648
  <summary>View Example</summary>
447
649
 
448
- ```js
449
- import { hexDataLength } from 'essential-eth';
650
+ ```js
651
+ import { hexConcat } from 'essential-eth';
652
+ ```
653
+
654
+ ```javascript
655
+ hexConcat([[2, 4, 0, 1], 9, '0x2934', '0x3947']);
656
+ // '0x020400010929343947'
450
657
  ```
451
658
 
452
- ```javascript
659
+ </details>
660
+
661
+ <br/>
662
+
663
+ #### [`hexDataLength`](https://eeth.dev/docs/api/modules#hexdatalength)
664
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexDataLength+}])
665
+ ```typescript
666
+ hexDataLength(data: BytesLike): undefined
667
+ ```
668
+
669
+ <details>
670
+ <summary>View Example</summary>
671
+
672
+ ```js
673
+ import { hexDataLength } from 'essential-eth';
674
+ ```
675
+
676
+ ```javascript
453
677
  hexDataLength([2, 4, 0, 1]);
454
678
  // 4
455
679
  ```
456
-
457
680
  ```javascript
458
681
  hexDataLength('0x3925');
459
682
  // 2
@@ -464,21 +687,19 @@ hexDataLength('0x3925');
464
687
  <br/>
465
688
 
466
689
  #### [`hexDataSlice`](https://eeth.dev/docs/api/modules#hexdataslice)
467
-
468
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexDataSlice+}])
469
-
470
- ```typescript
471
- hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset: number): string
472
- ```
473
-
690
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexDataSlice+}])
691
+ ```typescript
692
+ hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset: number): string
693
+ ```
694
+
474
695
  <details>
475
696
  <summary>View Example</summary>
476
697
 
477
- ```js
478
- import { hexDataSlice } from 'essential-eth';
479
- ```
698
+ ```js
699
+ import { hexDataSlice } from 'essential-eth';
700
+ ```
480
701
 
481
- ```javascript
702
+ ```javascript
482
703
  hexDataSlice([20, 6, 48], 0, 2);
483
704
  // '0x1406'
484
705
  ```
@@ -488,22 +709,20 @@ hexDataSlice([20, 6, 48], 0, 2);
488
709
  <br/>
489
710
 
490
711
  #### [`hexStripZeros`](https://eeth.dev/docs/api/modules#hexstripzeros)
491
-
492
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexStripZeros+}])
493
-
494
- ```typescript
495
- hexStripZeros(value: BytesLike): string
496
- ```
497
-
712
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexStripZeros+}])
713
+ ```typescript
714
+ hexStripZeros(value: BytesLike): string
715
+ ```
716
+
498
717
  <details>
499
718
  <summary>View Example</summary>
500
719
 
501
- ```js
502
- import { hexStripZeros } from 'essential-eth';
503
- ```
720
+ ```js
721
+ import { hexStripZeros } from 'essential-eth';
722
+ ```
504
723
 
505
- ```javascript
506
- hexStripZeros([0, 0, 0, 48]);
724
+ ```javascript
725
+ hexStripZeros([0,0,0,48]);
507
726
  // '0x30'
508
727
  ```
509
728
 
@@ -512,25 +731,22 @@ hexStripZeros([0, 0, 0, 48]);
512
731
  <br/>
513
732
 
514
733
  #### [`hexValue`](https://eeth.dev/docs/api/modules#hexvalue)
515
-
516
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexValue+}])
517
-
518
- ```typescript
519
- hexValue(value: number | bigint | BytesLike | Hexable): string
520
- ```
521
-
734
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexValue+}])
735
+ ```typescript
736
+ hexValue(value: number | bigint | BytesLike | Hexable): string
737
+ ```
738
+
522
739
  <details>
523
740
  <summary>View Example</summary>
524
741
 
525
- ```js
526
- import { hexValue } from 'essential-eth';
527
- ```
742
+ ```js
743
+ import { hexValue } from 'essential-eth';
744
+ ```
528
745
 
529
- ```javascript
746
+ ```javascript
530
747
  hexValue(39);
531
748
  // '0x27'
532
749
  ```
533
-
534
750
  ```javascript
535
751
  hexValue([9, 4, 19, 4]);
536
752
  // '0x9041304'
@@ -541,30 +757,26 @@ hexValue([9, 4, 19, 4]);
541
757
  <br/>
542
758
 
543
759
  #### [`hexZeroPad`](https://eeth.dev/docs/api/modules#hexzeropad)
544
-
545
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexZeroPad+}])
546
-
547
- ```typescript
548
- hexZeroPad(value: BytesLikeWithNumber, length: number): string
549
- ```
550
-
760
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexZeroPad+}])
761
+ ```typescript
762
+ hexZeroPad(value: BytesLikeWithNumber, length: number): string
763
+ ```
764
+
551
765
  <details>
552
766
  <summary>View Example</summary>
553
767
 
554
- ```js
555
- import { hexZeroPad } from 'essential-eth';
556
- ```
768
+ ```js
769
+ import { hexZeroPad } from 'essential-eth';
770
+ ```
557
771
 
558
- ```javascript
772
+ ```javascript
559
773
  hexZeroPad('0x60', 2);
560
774
  // '0x0060'
561
775
  ```
562
-
563
776
  ```javascript
564
777
  hexZeroPad(0x60, 3);
565
778
  // '0x000060'
566
779
  ```
567
-
568
780
  ```javascript
569
781
  hexZeroPad('12345', 1);
570
782
  // Throws
@@ -575,25 +787,22 @@ hexZeroPad('12345', 1);
575
787
  <br/>
576
788
 
577
789
  #### [`hexlify`](https://eeth.dev/docs/api/modules#hexlify)
578
-
579
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexlify+}])
580
-
581
- ```typescript
582
- hexlify(value: number | bigint | BytesLike | Hexable, options: DataOptions): string
583
- ```
584
-
790
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+hexlify+}])
791
+ ```typescript
792
+ hexlify(value: number | bigint | BytesLike | Hexable, options: DataOptions): string
793
+ ```
794
+
585
795
  <details>
586
796
  <summary>View Example</summary>
587
797
 
588
- ```js
589
- import { hexlify } from 'essential-eth';
590
- ```
798
+ ```js
799
+ import { hexlify } from 'essential-eth';
800
+ ```
591
801
 
592
- ```javascript
802
+ ```javascript
593
803
  hexlify(4);
594
804
  // '0x04'
595
805
  ```
596
-
597
806
  ```javascript
598
807
  hexlify(14);
599
808
  // '0x0e'
@@ -603,31 +812,54 @@ hexlify(14);
603
812
 
604
813
  <br/>
605
814
 
606
- #### [`isAddress`](https://eeth.dev/docs/api/modules#isaddress)
815
+ #### [`id`](https://eeth.dev/docs/api/modules#id)
816
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+id+}])
817
+ ```typescript
818
+ id(text: string): string
819
+ ```
820
+
821
+ <details>
822
+ <summary>View Example</summary>
607
823
 
608
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isAddress+}])
824
+ ```js
825
+ import { id } from 'essential-eth';
826
+ ```
609
827
 
610
- ```typescript
611
- isAddress(address: string): boolean
828
+ ```javascript
829
+ id('Transfer(address,address,uint256)')
830
+ // '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
831
+ ```
832
+ ```javascript
833
+ // Get a function selector (first 4 bytes)
834
+ id('balanceOf(address)').slice(0, 10)
835
+ // '0x70a08231'
612
836
  ```
613
837
 
838
+ </details>
839
+
840
+ <br/>
841
+
842
+ #### [`isAddress`](https://eeth.dev/docs/api/modules#isaddress)
843
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isAddress+}])
844
+ ```typescript
845
+ isAddress(address: string): boolean
846
+ ```
847
+
614
848
  <details>
615
849
  <summary>View Example</summary>
616
850
 
617
- ```js
618
- import { isAddress } from 'essential-eth';
619
- ```
851
+ ```js
852
+ import { isAddress } from 'essential-eth';
853
+ ```
620
854
 
621
- ```javascript
855
+ ```javascript
622
856
  isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
623
857
  // true
624
858
  ```
625
-
626
859
  ```javascript
627
860
  isAddress('bad');
628
861
  // false
629
862
  ```
630
-
631
863
  ```javascript
632
864
  // Does NOT support ENS.
633
865
  isAddress('vitalik.eth');
@@ -639,30 +871,26 @@ isAddress('vitalik.eth');
639
871
  <br/>
640
872
 
641
873
  #### [`isBytes`](https://eeth.dev/docs/api/modules#isbytes)
642
-
643
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isBytes+}])
644
-
645
- ```typescript
646
- isBytes(value: any): value
647
- ```
648
-
874
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isBytes+}])
875
+ ```typescript
876
+ isBytes(value: any): value
877
+ ```
878
+
649
879
  <details>
650
880
  <summary>View Example</summary>
651
881
 
652
- ```js
653
- import { isBytes } from 'essential-eth';
654
- ```
882
+ ```js
883
+ import { isBytes } from 'essential-eth';
884
+ ```
655
885
 
656
- ```javascript
657
- isBytes([1, 2, 3]);
886
+ ```javascript
887
+ isBytes([1,2,3]);
658
888
  // true
659
889
  ```
660
-
661
890
  ```javascript
662
891
  isBytes(false);
663
892
  // false
664
893
  ```
665
-
666
894
  ```javascript
667
895
  isBytes(new Uint8Array(1));
668
896
  // true
@@ -673,30 +901,26 @@ isBytes(new Uint8Array(1));
673
901
  <br/>
674
902
 
675
903
  #### [`isBytesLike`](https://eeth.dev/docs/api/modules#isbyteslike)
676
-
677
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isBytesLike+}])
678
-
679
- ```typescript
680
- isBytesLike(value: any): value
681
- ```
682
-
904
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isBytesLike+}])
905
+ ```typescript
906
+ isBytesLike(value: any): value
907
+ ```
908
+
683
909
  <details>
684
910
  <summary>View Example</summary>
685
911
 
686
- ```js
687
- import { isBytesLike } from 'essential-eth';
688
- ```
912
+ ```js
913
+ import { isBytesLike } from 'essential-eth';
914
+ ```
689
915
 
690
- ```javascript
691
- isBytesLike([1, 2, 3]);
916
+ ```javascript
917
+ isBytesLike([1,2,3]);
692
918
  // true
693
919
  ```
694
-
695
920
  ```javascript
696
921
  isBytesLike(false);
697
922
  // false
698
923
  ```
699
-
700
924
  ```javascript
701
925
  isBytesLike(new Uint8Array(1));
702
926
  // true
@@ -707,25 +931,22 @@ isBytesLike(new Uint8Array(1));
707
931
  <br/>
708
932
 
709
933
  #### [`isHexString`](https://eeth.dev/docs/api/modules#ishexstring)
710
-
711
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isHexString+}])
712
-
713
- ```typescript
714
- isHexString(value: any, length: number): boolean
715
- ```
716
-
934
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+isHexString+}])
935
+ ```typescript
936
+ isHexString(value: any, length: number): boolean
937
+ ```
938
+
717
939
  <details>
718
940
  <summary>View Example</summary>
719
941
 
720
- ```js
721
- import { isHexString } from 'essential-eth';
722
- ```
942
+ ```js
943
+ import { isHexString } from 'essential-eth';
944
+ ```
723
945
 
724
- ```javascript
946
+ ```javascript
725
947
  isHexString('0x4924');
726
948
  // true
727
949
  ```
728
-
729
950
  ```javascript
730
951
  isHexString('0x4924', 4);
731
952
  // false
@@ -737,26 +958,22 @@ isHexString('0x4924', 4);
737
958
  <br/>
738
959
 
739
960
  #### [`jsonRpcProvider`](https://eeth.dev/docs/api/modules#jsonrpcprovider)
740
-
741
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+jsonRpcProvider+}])
742
-
743
- ```typescript
744
- jsonRpcProvider(rpcUrl: string): JsonRpcProvider
745
- ```
746
-
961
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+jsonRpcProvider+}])
962
+ ```typescript
963
+ jsonRpcProvider(rpcUrl: string): JsonRpcProvider
964
+ ```
965
+
747
966
  <details>
748
967
  <summary>View Example</summary>
749
968
 
750
- ```js
751
- import { jsonRpcProvider } from 'essential-eth';
752
- ```
969
+ ```js
970
+ import { jsonRpcProvider } from 'essential-eth';
971
+ ```
753
972
 
754
- ```javascript
755
- jsonRpcProvider()
756
- .getBlock('latest')
757
- .then((block) => {
758
- console.log(block.number);
759
- });
973
+ ```javascript
974
+ jsonRpcProvider().getBlock('latest').then(block => {
975
+ console.log(block.number);
976
+ })
760
977
  // 14530496
761
978
  ```
762
979
 
@@ -765,21 +982,19 @@ jsonRpcProvider()
765
982
  <br/>
766
983
 
767
984
  #### [`keccak256`](https://eeth.dev/docs/api/modules#keccak256)
768
-
769
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+keccak256+}])
770
-
771
- ```typescript
772
- keccak256(data: BytesLike): string
773
- ```
774
-
985
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+keccak256+}])
986
+ ```typescript
987
+ keccak256(data: BytesLike): string
988
+ ```
989
+
775
990
  <details>
776
991
  <summary>View Example</summary>
777
992
 
778
- ```js
779
- import { keccak256 } from 'essential-eth';
780
- ```
993
+ ```js
994
+ import { keccak256 } from 'essential-eth';
995
+ ```
781
996
 
782
- ```javascript
997
+ ```javascript
783
998
  keccak256('essential-eth');
784
999
  // '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
785
1000
 
@@ -791,22 +1006,48 @@ keccak256('0x123');
791
1006
 
792
1007
  <br/>
793
1008
 
794
- #### [`pack`](https://eeth.dev/docs/api/modules#pack)
1009
+ #### [`namehash`](https://eeth.dev/docs/api/modules#namehash)
1010
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+namehash+}])
1011
+ ```typescript
1012
+ namehash(name: string): string
1013
+ ```
1014
+
1015
+ <details>
1016
+ <summary>View Example</summary>
795
1017
 
796
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+pack+}])
1018
+ ```js
1019
+ import { namehash } from 'essential-eth';
1020
+ ```
797
1021
 
798
- ```typescript
799
- pack(types: Array<string>, values: Array<any>): string
1022
+ ```javascript
1023
+ namehash('');
1024
+ // '0x0000000000000000000000000000000000000000000000000000000000000000'
1025
+
1026
+ namehash('eth');
1027
+ // '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae'
1028
+
1029
+ namehash('vitalik.eth');
1030
+ // '0xee6c4522aab0003e8d14cd40a6af439055fd2577951148c14b6cea9a53475835'
800
1031
  ```
801
1032
 
1033
+ </details>
1034
+
1035
+ <br/>
1036
+
1037
+ #### [`pack`](https://eeth.dev/docs/api/modules#pack)
1038
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+pack+}])
1039
+ ```typescript
1040
+ pack(types: Array<string>, values: Array<any>): string
1041
+ ```
1042
+
802
1043
  <details>
803
1044
  <summary>View Example</summary>
804
1045
 
805
- ```js
806
- import { pack } from 'essential-eth';
807
- ```
1046
+ ```js
1047
+ import { pack } from 'essential-eth';
1048
+ ```
808
1049
 
809
- ```javascript
1050
+ ```javascript
810
1051
  const types = ['bool', 'string', 'uint64'];
811
1052
  const values = [true, 'text', 30];
812
1053
  pack(types, values);
@@ -817,34 +1058,58 @@ pack(types, values);
817
1058
 
818
1059
  <br/>
819
1060
 
820
- #### [`solidityKeccak256`](https://eeth.dev/docs/api/modules#soliditykeccak256)
1061
+ #### [`parseUnits`](https://eeth.dev/docs/api/modules#parseunits)
1062
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+parseUnits+}])
1063
+ ```typescript
1064
+ parseUnits(value: string, decimals?: number): bigint
1065
+ ```
1066
+
1067
+ <details>
1068
+ <summary>View Example</summary>
821
1069
 
822
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+solidityKeccak256+}])
1070
+ ```js
1071
+ import { parseUnits } from 'essential-eth';
1072
+ ```
823
1073
 
824
- ```typescript
825
- solidityKeccak256(types: Array<string>, values: Array<any>): string
1074
+ ```javascript
1075
+ parseUnits('1', 6)
1076
+ // 1000000n
1077
+ ```
1078
+ ```javascript
1079
+ parseUnits('1.5', 6)
1080
+ // 1500000n
1081
+ ```
1082
+ ```javascript
1083
+ parseUnits('1', 18)
1084
+ // 1000000000000000000n
826
1085
  ```
827
1086
 
1087
+ </details>
1088
+
1089
+ <br/>
1090
+
1091
+ #### [`solidityKeccak256`](https://eeth.dev/docs/api/modules#soliditykeccak256)
1092
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+solidityKeccak256+}])
1093
+ ```typescript
1094
+ solidityKeccak256(types: Array<string>, values: Array<any>): string
1095
+ ```
1096
+
828
1097
  <details>
829
1098
  <summary>View Example</summary>
830
1099
 
831
- ```js
832
- import { solidityKeccak256 } from 'essential-eth';
833
- ```
1100
+ ```js
1101
+ import { solidityKeccak256 } from 'essential-eth';
1102
+ ```
834
1103
 
835
- ```javascript
1104
+ ```javascript
836
1105
  const types = ['string', 'bool', 'uint32'];
837
1106
  const values = ['essential-eth is great', true, 14];
838
1107
  solidityKeccak256(types, values);
839
1108
  // '0xe4d4c8e809faac09d58f468f0aeab9474fe8965d554c6c0f868c433c3fd6acab'
840
1109
  ```
841
-
842
1110
  ```javascript
843
1111
  const types = ['bytes4', 'uint32[5]'];
844
- const values = [
845
- [116, 101, 115, 116],
846
- [5, 3, 4, 9, 18],
847
- ];
1112
+ const values = [[116, 101, 115, 116], [5, 3, 4, 9, 18]];
848
1113
  solidityKeccak256(types, values);
849
1114
  // '0x038707a887f09355dc545412b058e7ba8f3c74047050c7c5e5e52eec608053d9'
850
1115
  ```
@@ -854,32 +1119,30 @@ solidityKeccak256(types, values);
854
1119
  <br/>
855
1120
 
856
1121
  #### [`splitSignature`](https://eeth.dev/docs/api/modules#splitsignature)
857
-
858
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+splitSignature+}])
859
-
860
- ```typescript
861
- splitSignature(signature: SignatureLike): Signature
862
- ```
863
-
1122
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+splitSignature+}])
1123
+ ```typescript
1124
+ splitSignature(signature: SignatureLike): Signature
1125
+ ```
1126
+
864
1127
  <details>
865
1128
  <summary>View Example</summary>
866
1129
 
867
- ```js
868
- import { splitSignature } from 'essential-eth';
869
- ```
1130
+ ```js
1131
+ import { splitSignature } from 'essential-eth';
1132
+ ```
870
1133
 
871
- ```javascript
1134
+ ```javascript
872
1135
  const signature = '0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee331b';
873
1136
  splitSignature(signature);
874
- {
875
- r: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b39716",
876
- s: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
877
- _vs: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
878
- recoveryParam: 0,
879
- v: 27,
880
- yParityAndS: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
881
- compact: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33"
882
- }
1137
+ {
1138
+ r: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b39716",
1139
+ s: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
1140
+ _vs: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
1141
+ recoveryParam: 0,
1142
+ v: 27,
1143
+ yParityAndS: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
1144
+ compact: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33"
1145
+ }
883
1146
  ```
884
1147
 
885
1148
  </details>
@@ -887,21 +1150,19 @@ splitSignature(signature);
887
1150
  <br/>
888
1151
 
889
1152
  #### [`stripZeros`](https://eeth.dev/docs/api/modules#stripzeros)
890
-
891
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+stripZeros+}])
892
-
893
- ```typescript
894
- stripZeros(value: BytesLike): Uint8Array
895
- ```
896
-
1153
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+stripZeros+}])
1154
+ ```typescript
1155
+ stripZeros(value: BytesLike): Uint8Array
1156
+ ```
1157
+
897
1158
  <details>
898
1159
  <summary>View Example</summary>
899
1160
 
900
- ```js
901
- import { stripZeros } from 'essential-eth';
902
- ```
1161
+ ```js
1162
+ import { stripZeros } from 'essential-eth';
1163
+ ```
903
1164
 
904
- ```javascript
1165
+ ```javascript
905
1166
  stripZeros('0x00002834');
906
1167
  // Uint8Array { [Iterator] 0: 40, 1: 52 }
907
1168
  // Equivalent to '0x2834'
@@ -911,50 +1172,25 @@ stripZeros('0x00002834');
911
1172
 
912
1173
  <br/>
913
1174
 
914
- #### [`tinyBig`](https://eeth.dev/docs/api/modules#tinybig)
915
-
916
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+tinyBig+}])
917
-
918
- ```typescript
919
- tinyBig(value: string | number | TinyBig | Big): TinyBig
920
- ```
921
-
922
- <details>
923
- <summary>View Example</summary>
924
-
925
- ```js
926
- import { tinyBig } from 'essential-eth';
927
- ```
928
-
929
- ```javascript
930
- tinyBig(10).times(3).toNumber();
931
- // 30
932
- ```
933
-
934
- </details>
935
-
936
- <br/>
937
-
938
1175
  #### [`toChecksumAddress`](https://eeth.dev/docs/api/modules#tochecksumaddress)
939
-
940
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+toChecksumAddress+}])
941
-
942
- ```typescript
943
- toChecksumAddress(address: string): string
944
- ```
945
-
1176
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+toChecksumAddress+}])
1177
+ ```typescript
1178
+ toChecksumAddress(address: string): string
1179
+ ```
1180
+
946
1181
  <details>
947
1182
  <summary>View Example</summary>
948
1183
 
949
- ```js
950
- import { toChecksumAddress } from 'essential-eth';
951
- ```
1184
+ ```js
1185
+ import { toChecksumAddress } from 'essential-eth';
1186
+ ```
952
1187
 
953
- ```javascript
1188
+ ```javascript
954
1189
  toChecksumAddress('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359');
955
1190
  // '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'
956
1191
  ```
957
1192
 
1193
+
958
1194
  Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v5/api/utils/address/#utils-getAddress)
959
1195
 
960
1196
  Similar to ["toChecksumAddress" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#tochecksumaddress)
@@ -964,21 +1200,19 @@ Similar to ["toChecksumAddress" in web3.js](https://web3js.readthedocs.io/en/v1.
964
1200
  <br/>
965
1201
 
966
1202
  #### [`toUtf8Bytes`](https://eeth.dev/docs/api/modules#toutf8bytes)
967
-
968
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+toUtf8Bytes+}])
969
-
970
- ```typescript
971
- toUtf8Bytes(data: string): Uint8Array
972
- ```
973
-
1203
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+toUtf8Bytes+}])
1204
+ ```typescript
1205
+ toUtf8Bytes(data: string): Uint8Array
1206
+ ```
1207
+
974
1208
  <details>
975
1209
  <summary>View Example</summary>
976
1210
 
977
- ```js
978
- import { toUtf8Bytes } from 'essential-eth';
979
- ```
1211
+ ```js
1212
+ import { toUtf8Bytes } from 'essential-eth';
1213
+ ```
980
1214
 
981
- ```javascript
1215
+ ```javascript
982
1216
  toUtf8Bytes('essential-eth');
983
1217
  // Uint8Array { [Iterator] 0: 101, 1: 115, 2: 115, 3: 101, 4: 110, 5: 116, 6: 105, 7: 97, 8: 108, 9: 45, 10: 101, 11: 116, 12: 104 }
984
1218
 
@@ -990,33 +1224,50 @@ toUtf8Bytes('ethereum');
990
1224
 
991
1225
  <br/>
992
1226
 
993
- #### [`weiToEther`](https://eeth.dev/docs/api/modules#weitoether)
1227
+ #### [`toUtf8String`](https://eeth.dev/docs/api/modules#toutf8string)
1228
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+toUtf8String+}])
1229
+ ```typescript
1230
+ toUtf8String(bytes: BytesLike): string
1231
+ ```
1232
+
1233
+ <details>
1234
+ <summary>View Example</summary>
994
1235
 
995
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+weiToEther+}])
1236
+ ```js
1237
+ import { toUtf8String } from 'essential-eth';
1238
+ ```
996
1239
 
997
- ```typescript
998
- weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig
1240
+ ```javascript
1241
+ toUtf8String(new Uint8Array([101, 116, 104]))
1242
+ // 'eth'
999
1243
  ```
1244
+ ```javascript
1245
+ toUtf8String('0x657468')
1246
+ // 'eth'
1247
+ ```
1248
+
1249
+ </details>
1250
+
1251
+ <br/>
1000
1252
 
1253
+ #### [`weiToEther`](https://eeth.dev/docs/api/modules#weitoether)
1254
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+weiToEther+}])
1255
+ ```typescript
1256
+ weiToEther(weiQuantity: string | number | bigint): string
1257
+ ```
1258
+
1001
1259
  <details>
1002
1260
  <summary>View Example</summary>
1003
1261
 
1004
- ```js
1005
- import { weiToEther } from 'essential-eth';
1006
- ```
1262
+ ```js
1263
+ import { weiToEther } from 'essential-eth';
1264
+ ```
1007
1265
 
1008
- ```javascript
1009
- weiToEther('1000000000000000000000').toString();
1266
+ ```javascript
1267
+ weiToEther('1000000000000000000000')
1010
1268
  // '1000'
1011
- weiToEther(1000000000000000000000).toString();
1269
+ weiToEther(1000000000000000000000)
1012
1270
  // '1000'
1013
- ```
1014
-
1015
- ```javascript
1016
- weiToEther('1000000000000000000000').toNumber();
1017
- // 1000
1018
- weiToEther(1000000000000000000000).toNumber();
1019
- // 1000
1020
1271
  ```
1021
1272
 
1022
1273
  </details>
@@ -1024,26 +1275,23 @@ weiToEther(1000000000000000000000).toNumber();
1024
1275
  <br/>
1025
1276
 
1026
1277
  #### [`zeroPad`](https://eeth.dev/docs/api/modules#zeropad)
1027
-
1028
- ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+zeroPad+}])
1029
-
1030
- ```typescript
1031
- zeroPad(value: BytesLike, length: number): Uint8Array
1032
- ```
1033
-
1278
+ ![](https://deno.bundlejs.com/badge?q=essential-eth&treeshake=[{+zeroPad+}])
1279
+ ```typescript
1280
+ zeroPad(value: BytesLike, length: number): Uint8Array
1281
+ ```
1282
+
1034
1283
  <details>
1035
1284
  <summary>View Example</summary>
1036
1285
 
1037
- ```js
1038
- import { zeroPad } from 'essential-eth';
1039
- ```
1286
+ ```js
1287
+ import { zeroPad } from 'essential-eth';
1288
+ ```
1040
1289
 
1041
- ```javascript
1290
+ ```javascript
1042
1291
  zeroPad('0x039284');
1043
1292
  // Uint8Array { [Iterator] 0: 0, 1: 0, 2: 0, 3: 3, 4: 146, 5: 132 }
1044
1293
  // Equivalent to 0x000000039284
1045
1294
  ```
1046
-
1047
1295
  ```javascript
1048
1296
  zeroPad([39, 25, 103, 45], 5);
1049
1297
  // Uint8Array { [Iterator] 0: 0, 1: 39, 2: 25, 3: 103, 4: 45 }
@@ -1053,6 +1301,8 @@ zeroPad([39, 25, 103, 45], 5);
1053
1301
 
1054
1302
  <br/>
1055
1303
 
1304
+
1305
+
1056
1306
  <!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
1057
1307
 
1058
1308
  - _The return-type `TinyBig` is just [`Big`](https://github.com/MikeMcl/big.js) but expands scientific notation on `toNumber()` and `toString()`_
@@ -1092,8 +1342,8 @@ provider.getGasPrice().toNumber();
1092
1342
 
1093
1343
  <br/>
1094
1344
 
1095
- <!-- ⛔️ AUTO-GENERATED-CONTENT:START (PROVIDER) -->
1096
1345
 
1346
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:START (PROVIDER) -->
1097
1347
  #### [`call`](https://eeth.dev/docs/api/classes/JsonRpcProvider#call)
1098
1348
 
1099
1349
  ```typescript
@@ -1558,6 +1808,39 @@ await provider.getTransactionReceipt(
1558
1808
 
1559
1809
  <br/>
1560
1810
 
1811
+ #### [`resolveName`](https://eeth.dev/docs/api/classes/JsonRpcProvider#resolvename)
1812
+
1813
+ ```typescript
1814
+ provider.resolveName(name: string): Promise<string | null>
1815
+ ```
1816
+
1817
+ Resolves an ENS name to an Ethereum address. Returns `null` if the name has no resolver or no address set.
1818
+
1819
+ Similar to ["resolveName" in ethers.js](https://docs.ethers.io/v5/api/providers/provider/#Provider-ResolveName)
1820
+
1821
+ <details>
1822
+ <summary>View Example</summary>
1823
+
1824
+ ```js
1825
+ import { JsonRpcProvider } from 'essential-eth';
1826
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1827
+ ```
1828
+
1829
+ ```javascript
1830
+ await provider.resolveName('vitalik.eth');
1831
+ // '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
1832
+
1833
+ await provider.resolveName('daws.eth');
1834
+ // '0x5C389...' (resolved address)
1835
+
1836
+ await provider.resolveName('thisdoesnotexist12345.eth');
1837
+ // null
1838
+ ```
1839
+
1840
+ </details>
1841
+
1842
+ <br/>
1843
+
1561
1844
  <!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
1562
1845
 
1563
1846
  <br/>