essential-eth 0.5.4 → 0.5.9

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.
Files changed (98) hide show
  1. package/lib/cjs/classes/Contract.d.ts +10 -4
  2. package/lib/cjs/classes/Contract.js +15 -4
  3. package/lib/cjs/classes/utils/clean-block.d.ts +115 -0
  4. package/lib/cjs/classes/utils/clean-block.js +122 -9
  5. package/lib/cjs/classes/utils/clean-log.d.ts +9 -0
  6. package/lib/cjs/classes/utils/clean-log.js +37 -0
  7. package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +9 -0
  8. package/lib/cjs/classes/utils/clean-transaction-receipt.js +11 -16
  9. package/lib/cjs/classes/utils/clean-transaction.d.ts +9 -0
  10. package/lib/cjs/classes/utils/clean-transaction.js +10 -1
  11. package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +12 -0
  12. package/lib/cjs/classes/utils/encode-decode-transaction.js +24 -0
  13. package/lib/cjs/classes/utils/fetchers.d.ts +31 -1
  14. package/lib/cjs/classes/utils/fetchers.js +30 -0
  15. package/lib/cjs/classes/utils/hex-to-decimal.d.ts +14 -1
  16. package/lib/cjs/classes/utils/hex-to-decimal.js +14 -1
  17. package/lib/cjs/classes/utils/prepare-transaction.d.ts +6 -0
  18. package/lib/cjs/classes/utils/prepare-transaction.js +45 -0
  19. package/lib/cjs/index.d.ts +10 -5
  20. package/lib/cjs/index.js +10 -2
  21. package/lib/cjs/logger/package-version.d.ts +1 -1
  22. package/lib/cjs/logger/package-version.js +1 -1
  23. package/lib/cjs/providers/BaseProvider.d.ts +282 -199
  24. package/lib/cjs/providers/BaseProvider.js +365 -214
  25. package/lib/cjs/providers/FallthroughProvider.d.ts +1 -2
  26. package/lib/cjs/providers/JsonRpcProvider.d.ts +6 -0
  27. package/lib/cjs/providers/JsonRpcProvider.js +6 -0
  28. package/lib/cjs/providers/utils/chains-info.d.ts +27 -0
  29. package/lib/cjs/providers/utils/chains-info.js +84 -3
  30. package/lib/cjs/shared/tiny-big/helpers.d.ts +16 -0
  31. package/lib/cjs/shared/tiny-big/helpers.js +27 -1
  32. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +30 -4
  33. package/lib/cjs/shared/tiny-big/tiny-big.js +34 -4
  34. package/lib/cjs/types/Block.types.d.ts +11 -7
  35. package/lib/cjs/types/Filter.types.d.ts +16 -0
  36. package/lib/cjs/types/Filter.types.js +2 -0
  37. package/lib/cjs/types/Transaction.types.d.ts +33 -6
  38. package/lib/cjs/utils/bytes.d.ts +150 -33
  39. package/lib/cjs/utils/bytes.js +179 -32
  40. package/lib/cjs/utils/compute-address.d.ts +17 -0
  41. package/lib/cjs/utils/compute-address.js +33 -0
  42. package/lib/cjs/utils/compute-public-key.d.ts +18 -0
  43. package/lib/cjs/utils/compute-public-key.js +26 -0
  44. package/lib/cjs/utils/ether-to-gwei.d.ts +2 -1
  45. package/lib/cjs/utils/ether-to-gwei.js +2 -1
  46. package/lib/cjs/utils/ether-to-wei.d.ts +2 -1
  47. package/lib/cjs/utils/ether-to-wei.js +2 -1
  48. package/lib/cjs/utils/gwei-to-ether.d.ts +2 -1
  49. package/lib/cjs/utils/gwei-to-ether.js +2 -1
  50. package/lib/cjs/utils/hash-message.d.ts +3 -1
  51. package/lib/cjs/utils/hash-message.js +3 -1
  52. package/lib/cjs/utils/is-address.d.ts +2 -2
  53. package/lib/cjs/utils/is-address.js +2 -2
  54. package/lib/cjs/utils/keccak256.d.ts +15 -1
  55. package/lib/cjs/utils/keccak256.js +16 -2
  56. package/lib/cjs/utils/solidity-keccak256.d.ts +17 -7
  57. package/lib/cjs/utils/solidity-keccak256.js +27 -7
  58. package/lib/cjs/utils/split-signature.d.ts +24 -0
  59. package/lib/cjs/utils/split-signature.js +163 -0
  60. package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
  61. package/lib/cjs/utils/to-checksum-address.js +2 -2
  62. package/lib/cjs/utils/to-utf8-bytes.d.ts +14 -0
  63. package/lib/cjs/utils/to-utf8-bytes.js +14 -0
  64. package/lib/cjs/utils/wei-to-ether.d.ts +2 -1
  65. package/lib/cjs/utils/wei-to-ether.js +14 -3
  66. package/lib/esm/classes/utils/clean-block.js +7 -8
  67. package/lib/esm/classes/utils/clean-log.d.ts +2 -0
  68. package/lib/esm/classes/utils/clean-log.js +26 -0
  69. package/lib/esm/classes/utils/clean-transaction-receipt.js +2 -16
  70. package/lib/esm/classes/utils/clean-transaction.js +1 -1
  71. package/lib/esm/classes/utils/fetchers.d.ts +1 -1
  72. package/lib/esm/classes/utils/prepare-transaction.d.ts +2 -0
  73. package/lib/esm/classes/utils/prepare-transaction.js +34 -0
  74. package/lib/esm/index.d.ts +10 -5
  75. package/lib/esm/index.js +7 -3
  76. package/lib/esm/logger/package-version.d.ts +1 -1
  77. package/lib/esm/logger/package-version.js +1 -1
  78. package/lib/esm/providers/BaseProvider.d.ts +7 -1
  79. package/lib/esm/providers/BaseProvider.js +67 -11
  80. package/lib/esm/providers/FallthroughProvider.d.ts +1 -2
  81. package/lib/esm/providers/utils/chains-info.d.ts +27 -0
  82. package/lib/esm/providers/utils/chains-info.js +84 -3
  83. package/lib/esm/shared/tiny-big/tiny-big.js +4 -0
  84. package/lib/esm/types/Block.types.d.ts +11 -7
  85. package/lib/esm/types/Filter.types.d.ts +12 -0
  86. package/lib/esm/types/Filter.types.js +1 -0
  87. package/lib/esm/types/Transaction.types.d.ts +31 -5
  88. package/lib/esm/utils/compute-address.d.ts +1 -0
  89. package/lib/esm/utils/compute-address.js +11 -0
  90. package/lib/esm/utils/compute-public-key.d.ts +2 -0
  91. package/lib/esm/utils/compute-public-key.js +6 -0
  92. package/lib/esm/utils/keccak256.d.ts +1 -1
  93. package/lib/esm/utils/keccak256.js +2 -2
  94. package/lib/esm/utils/split-signature.d.ts +2 -0
  95. package/lib/esm/utils/split-signature.js +126 -0
  96. package/lib/esm/utils/wei-to-ether.js +11 -2
  97. package/package.json +38 -11
  98. package/readme.md +1209 -335
package/readme.md CHANGED
@@ -8,12 +8,10 @@
8
8
  🪶 Essential Eth 🪶
9
9
  </b>
10
10
  <br/>
11
- <i>A replacement for ethers & web3 that's 20x smaller</i>
11
+ <i>An alternative for ethers & web3 that's 20x smaller</i>
12
12
  <br/>
13
13
  </p>
14
14
 
15
- ---
16
-
17
15
  <br/>
18
16
 
19
17
  ## Why you should replace Ethers.js and web3
@@ -24,6 +22,8 @@
24
22
 
25
23
  ---
26
24
 
25
+ [![🧪 tests](https://github.com/Earnifi/essential-eth/actions/workflows/test.yml/badge.svg)](https://github.com/Earnifi/essential-eth/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/Earnifi/essential-eth/branch/master/graph/badge.svg?token=E44EK6RWTZ)](https://codecov.io/gh/Earnifi/essential-eth) ![](https://badgen.net/bundlephobia/minzip/essential-eth) ![](https://badgen.net/bundlephobia/tree-shaking/essential-eth) ![](https://img.shields.io/npm/v/essential-eth)
26
+
27
27
  <br/>
28
28
 
29
29
  - 🏆️ <sub><sup>[smallest code size possible](https://bundlephobia.com/package/essential-eth)</sup></sub>
@@ -32,231 +32,942 @@
32
32
  - - ⚡️ Near-identical API to `ethers`
33
33
  - 🌲 Tree-shaking and no side-effects
34
34
  - 🙌 Supports multiple JS versions (CommonJS and ESM)
35
- - ✅ Node 17, 16, 14, & 12
35
+ - ✅ Node 18, 16, 14, & 12
36
36
  - ✅ Web
37
37
 
38
38
  <br/>
39
39
 
40
- [![🧪 tests](https://github.com/Earnifi/essential-eth/actions/workflows/test.yml/badge.svg)](https://github.com/Earnifi/essential-eth/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/Earnifi/essential-eth/branch/master/graph/badge.svg?token=E44EK6RWTZ)](https://codecov.io/gh/Earnifi/essential-eth) ![](https://badgen.net/bundlephobia/minzip/essential-eth) ![](https://badgen.net/bundlephobia/tree-shaking/essential-eth) ![](https://img.shields.io/npm/v/essential-eth)
40
+ ## Table of Contents
41
41
 
42
- <br/>
42
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:START (TOC:collapse=true&collapseText=Click to expand) -->
43
+ <details>
44
+ <summary>Click to expand</summary>
45
+
46
+ - [Why you should replace Ethers.js and web3](#why-you-should-replace-ethersjs-and-web3)
47
+ - [Install](#install)
48
+ - [🛠 Utils](#-utils)
49
+ - [`arrayify`](#arrayify)
50
+ - [`computeAddress`](#computeaddress)
51
+ - [`computePublicKey`](#computepublickey)
52
+ - [`concat`](#concat)
53
+ - [`etherToGwei`](#ethertogwei)
54
+ - [`etherToWei`](#ethertowei)
55
+ - [`gweiToEther`](#gweitoether)
56
+ - [`hashMessage`](#hashmessage)
57
+ - [`hexConcat`](#hexconcat)
58
+ - [`hexDataLength`](#hexdatalength)
59
+ - [`hexDataSlice`](#hexdataslice)
60
+ - [`hexStripZeros`](#hexstripzeros)
61
+ - [`hexValue`](#hexvalue)
62
+ - [`hexZeroPad`](#hexzeropad)
63
+ - [`hexlify`](#hexlify)
64
+ - [`isAddress`](#isaddress)
65
+ - [`isBytes`](#isbytes)
66
+ - [`isBytesLike`](#isbyteslike)
67
+ - [`isHexString`](#ishexstring)
68
+ - [`jsonRpcProvider`](#jsonrpcprovider)
69
+ - [`keccak256`](#keccak256)
70
+ - [`pack`](#pack)
71
+ - [`solidityKeccak256`](#soliditykeccak256)
72
+ - [`splitSignature`](#splitsignature)
73
+ - [`stripZeros`](#stripzeros)
74
+ - [`tinyBig`](#tinybig)
75
+ - [`toChecksumAddress`](#tochecksumaddress)
76
+ - [`toUtf8Bytes`](#toutf8bytes)
77
+ - [`weiToEther`](#weitoether)
78
+ - [`zeroPad`](#zeropad)
79
+ - [Providers](#providers)
80
+ - [`call`](#call)
81
+ - [`estimateGas`](#estimategas)
82
+ - [`getBalance`](#getbalance)
83
+ - [`getBlock`](#getblock)
84
+ - [`getBlockNumber`](#getblocknumber)
85
+ - [`getCode`](#getcode)
86
+ - [`getGasPrice`](#getgasprice)
87
+ - [`getLogs`](#getlogs)
88
+ - [`getNetwork`](#getnetwork)
89
+ - [`getTransaction`](#gettransaction)
90
+ - [`getTransactionCount`](#gettransactioncount)
91
+ - [`getTransactionReceipt`](#gettransactionreceipt)
92
+ - [Contract](#contract)
93
+ - [`contractFunctionName(args)`](#contractfunctionnameargs)
94
+ - [More Info](#more-info)
95
+ - [Identical vs Similar vs Dissimliar {&#035;isd}](#identical-vs-similar-vs-dissimliar-isd)
96
+ - [Miscellaneous](#miscellaneous)
97
+
98
+ </details>
99
+
100
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
101
+
102
+ <br/>
43
103
 
44
104
  ## Install
45
105
 
46
106
  ```sh
47
107
  npm install --save essential-eth # TypeScript types load automatically
48
108
 
49
- # or if you prefer yarn
109
+ # or yarn
50
110
  yarn add essential-eth # TypeScript types load automatically
51
111
  ```
52
112
 
53
113
  <br/>
54
114
 
55
- ## Utils (do not require connecting to an Eth node)
115
+ ## 🛠 Utils
116
+
117
+ ```typescript
118
+ import { etherToWei } from 'essential-eth';
119
+
120
+ // or in a non-import environment
121
+ const { etherToWei } = require('essential-eth');
122
+ ```
123
+
124
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:START (FUNCTIONS) -->
125
+
126
+ #### [`arrayify`](https://essential-eth.vercel.app/docs/api/modules#arrayify)
127
+
128
+ ```typescript
129
+ arrayify(value: number | BytesLike | Hexable, options: DataOptions): Uint8Array
130
+ ```
131
+
132
+ <details>
133
+ <summary>View Example</summary>
134
+
135
+ ```js
136
+ import { arrayify } from 'essential-eth';
137
+ ```
138
+
139
+ ```javascript
140
+ arrayify(1);
141
+ // Uint8Array(1) [ 1 ]
142
+ ```
143
+
144
+ ```javascript
145
+ arrayify(0x1234);
146
+ // Uint8Array(2) [ 18, 52 ]
147
+ ```
148
+
149
+ ```javascript
150
+ arrayify('0x1', { hexPad: 'right' });
151
+ // Uint8Array(1) [ 16 ]
152
+ ```
153
+
154
+ </details>
155
+
156
+ <br/>
157
+
158
+ #### [`computeAddress`](https://essential-eth.vercel.app/docs/api/modules#computeaddress)
159
+
160
+ ```typescript
161
+ computeAddress(key: string): string
162
+ ```
163
+
164
+ <details>
165
+ <summary>View Example</summary>
166
+
167
+ ```js
168
+ import { computeAddress } from 'essential-eth';
169
+ ```
170
+
171
+ ```javascript
172
+ computeAddress(
173
+ '0x0458eb591f407aef12936bd2989ca699cf5061de9c4964dd6eb6005fd8f580c407434447e813969a1be6e9954b002cad84dfc67a69e032b273e4695e7d0db2d952',
174
+ ); // public key
175
+ // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
176
+ ```
177
+
178
+ ```javascript
179
+ computeAddress(
180
+ '0x2f2c419acf4a1da8c1ebea75bb3fcfbd3ec2aa3bf0162901ccdc2f38b8f92427',
181
+ ); // private key
182
+ // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
183
+ ```
184
+
185
+ </details>
186
+
187
+ <br/>
188
+
189
+ #### [`computePublicKey`](https://essential-eth.vercel.app/docs/api/modules#computepublickey)
190
+
191
+ ```typescript
192
+ computePublicKey(privKey: BytesLike): string
193
+ ```
194
+
195
+ <details>
196
+ <summary>View Example</summary>
197
+
198
+ ```js
199
+ import { computePublicKey } from 'essential-eth';
200
+ ```
201
+
202
+ ```javascript
203
+ computePublicKey(
204
+ '0xb27cc8dea0177d910110e8d3ec5480d56c723abf433529f4063f261ffdb9297c',
205
+ );
206
+ // '0x045cd0032015eecfde49f82f4e149d804e8ac6e3a0bface32e37c72a71ceac864fe84da7e8df84342f7b11dfb753c4d158f636142b46b29cf7f0f171ae0aa4fb87'
207
+ ```
208
+
209
+ ```javascript
210
+ computePublicKey([
211
+ 50, 102, 50, 99, 52, 49, 57, 97, 99, 102, 52, 97, 49, 100, 97, 56, 99, 49,
212
+ 101, 98, 101, 97, 55, 53, 98, 98, 51, 102, 99, 102, 98, 100,
213
+ ]);
214
+ // '0x04a9cea77eca949df84f661cee153426fb51f2294b9364b4fac240df57360b9b0ac9c99e4d7966491ab4c81f8c82e0cd24ec5759832ad4ab736d22c7d90b806ee8'
215
+ ```
216
+
217
+ </details>
218
+
219
+ <br/>
220
+
221
+ #### [`concat`](https://essential-eth.vercel.app/docs/api/modules#concat)
222
+
223
+ ```typescript
224
+ concat(arrayOfBytesLike: Array<BytesLikeWithNumber>): Uint8Array
225
+ ```
226
+
227
+ <details>
228
+ <summary>View Example</summary>
229
+
230
+ ```js
231
+ import { concat } from 'essential-eth';
232
+ ```
233
+
234
+ ```javascript
235
+ concat([0, 1]);
236
+ // Uint8Array(2) [ 0, 1 ]
237
+ ```
238
+
239
+ </details>
240
+
241
+ <br/>
242
+
243
+ #### [`etherToGwei`](https://essential-eth.vercel.app/docs/api/modules#ethertogwei)
244
+
245
+ ```typescript
246
+ etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig
247
+ ```
248
+
249
+ <details>
250
+ <summary>View Example</summary>
251
+
252
+ ```js
253
+ import { etherToGwei } from 'essential-eth';
254
+ ```
255
+
256
+ ```javascript
257
+ etherToGwei('1000').toString();
258
+ // '1000000000000'
259
+ etherToGwei(1000).toString();
260
+ // '1000000000000'
261
+ ```
262
+
263
+ ```javascript
264
+ etherToGwei('1000').toNumber();
265
+ // 1000000000000
266
+ etherToGwei(1000).toNumber();
267
+ // 1000000000000
268
+ ```
269
+
270
+ </details>
271
+
272
+ <br/>
273
+
274
+ #### [`etherToWei`](https://essential-eth.vercel.app/docs/api/modules#ethertowei)
56
275
 
57
276
  ```typescript
277
+ etherToWei(etherQuantity: string | number | TinyBig | Big): TinyBig
278
+ ```
279
+
280
+ <details>
281
+ <summary>View Example</summary>
282
+
283
+ ```js
58
284
  import { etherToWei } from 'essential-eth';
285
+ ```
286
+
287
+ ```javascript
288
+ etherToWei('1000').toString();
289
+ // '1000000000000000000000'
290
+ etherToWei(1000).toString();
291
+ // '1000000000000000000000'
292
+ ```
293
+
294
+ ```javascript
295
+ etherToWei('1000').toNumber();
296
+ // 1000000000000000000000
297
+ etherToWei(1000).toNumber();
298
+ // 1000000000000000000000
299
+ ```
300
+
301
+ </details>
302
+
303
+ <br/>
304
+
305
+ #### [`gweiToEther`](https://essential-eth.vercel.app/docs/api/modules#gweitoether)
306
+
307
+ ```typescript
308
+ gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig
309
+ ```
310
+
311
+ <details>
312
+ <summary>View Example</summary>
313
+
314
+ ```js
315
+ import { gweiToEther } from 'essential-eth';
316
+ ```
317
+
318
+ ```javascript
319
+ gweiToEther('1000000000000').toString();
320
+ // '1000'
321
+ gweiToEther(1000000000000).toString();
322
+ // '1000'
323
+ ```
324
+
325
+ ```javascript
326
+ gweiToEther('1000000000000').toNumber();
327
+ // 1000
328
+ gweiToEther(1000000000000).toNumber();
329
+ // 1000
330
+ ```
331
+
332
+ </details>
333
+
334
+ <br/>
335
+
336
+ #### [`hashMessage`](https://essential-eth.vercel.app/docs/api/modules#hashmessage)
337
+
338
+ ```typescript
339
+ hashMessage(message: string | Bytes): string
340
+ ```
341
+
342
+ <details>
343
+ <summary>View Example</summary>
344
+
345
+ ```js
346
+ import { hashMessage } from 'essential-eth';
347
+ ```
348
+
349
+ ```javascript
350
+ hashMessage('Hello World');
351
+ // '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
352
+ ```
353
+
354
+ </details>
355
+
356
+ <br/>
357
+
358
+ #### [`hexConcat`](https://essential-eth.vercel.app/docs/api/modules#hexconcat)
359
+
360
+ ```typescript
361
+ hexConcat(items: Array<BytesLike>): string
362
+ ```
363
+
364
+ <details>
365
+ <summary>View Example</summary>
366
+
367
+ ```js
368
+ import { hexConcat } from 'essential-eth';
369
+ ```
370
+
371
+ ```javascript
372
+ hexConcat([[2, 4, 0, 1], 9, '0x2934', '0x3947']);
373
+ // '0x020400010929343947'
374
+ ```
375
+
376
+ </details>
377
+
378
+ <br/>
379
+
380
+ #### [`hexDataLength`](https://essential-eth.vercel.app/docs/api/modules#hexdatalength)
381
+
382
+ ```typescript
383
+ hexDataLength(data: BytesLike): undefined
384
+ ```
385
+
386
+ <details>
387
+ <summary>View Example</summary>
388
+
389
+ ```js
390
+ import { hexDataLength } from 'essential-eth';
391
+ ```
392
+
393
+ ```javascript
394
+ hexDataLength([2, 4, 0, 1]);
395
+ // 4
396
+ ```
397
+
398
+ ```javascript
399
+ hexDataLength('0x3925');
400
+ // 2
401
+ ```
402
+
403
+ </details>
404
+
405
+ <br/>
406
+
407
+ #### [`hexDataSlice`](https://essential-eth.vercel.app/docs/api/modules#hexdataslice)
408
+
409
+ ```typescript
410
+ hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset: number): string
411
+ ```
412
+
413
+ <details>
414
+ <summary>View Example</summary>
415
+
416
+ ```js
417
+ import { hexDataSlice } from 'essential-eth';
418
+ ```
419
+
420
+ ```javascript
421
+ hexDataSlice([20, 6, 48], 0, 2);
422
+ // '0x1406'
423
+ ```
424
+
425
+ </details>
426
+
427
+ <br/>
428
+
429
+ #### [`hexStripZeros`](https://essential-eth.vercel.app/docs/api/modules#hexstripzeros)
430
+
431
+ ```typescript
432
+ hexStripZeros(value: BytesLike): string
433
+ ```
434
+
435
+ <details>
436
+ <summary>View Example</summary>
437
+
438
+ ```js
439
+ import { hexStripZeros } from 'essential-eth';
440
+ ```
441
+
442
+ ```javascript
443
+ hexStripZeros([0, 0, 0, 48]);
444
+ // '0x30'
445
+ ```
446
+
447
+ </details>
448
+
449
+ <br/>
450
+
451
+ #### [`hexValue`](https://essential-eth.vercel.app/docs/api/modules#hexvalue)
452
+
453
+ ```typescript
454
+ hexValue(value: number | bigint | BytesLike | Hexable): string
455
+ ```
456
+
457
+ <details>
458
+ <summary>View Example</summary>
459
+
460
+ ```js
461
+ import { hexValue } from 'essential-eth';
462
+ ```
463
+
464
+ ```javascript
465
+ hexValue(39);
466
+ // '0x27'
467
+ ```
468
+
469
+ ```javascript
470
+ hexValue([9, 4, 19, 4]);
471
+ // '0x9041304'
472
+ ```
473
+
474
+ </details>
475
+
476
+ <br/>
477
+
478
+ #### [`hexZeroPad`](https://essential-eth.vercel.app/docs/api/modules#hexzeropad)
479
+
480
+ ```typescript
481
+ hexZeroPad(value: BytesLikeWithNumber, length: number): string
482
+ ```
483
+
484
+ <details>
485
+ <summary>View Example</summary>
486
+
487
+ ```js
488
+ import { hexZeroPad } from 'essential-eth';
489
+ ```
490
+
491
+ ```javascript
492
+ hexZeroPad('0x60', 2);
493
+ // '0x0060'
494
+ ```
495
+
496
+ ```javascript
497
+ hexZeroPad(0x60, 3);
498
+ // '0x000060'
499
+ ```
500
+
501
+ ```javascript
502
+ hexZeroPad('12345', 1);
503
+ // Throws
504
+ ```
505
+
506
+ </details>
507
+
508
+ <br/>
509
+
510
+ #### [`hexlify`](https://essential-eth.vercel.app/docs/api/modules#hexlify)
511
+
512
+ ```typescript
513
+ hexlify(value: number | bigint | BytesLike | Hexable, options: DataOptions): string
514
+ ```
515
+
516
+ <details>
517
+ <summary>View Example</summary>
518
+
519
+ ```js
520
+ import { hexlify } from 'essential-eth';
521
+ ```
522
+
523
+ ```javascript
524
+ hexlify(4);
525
+ // '0x04'
526
+ ```
527
+
528
+ ```javascript
529
+ hexlify(14);
530
+ // '0x0e'
531
+ ```
532
+
533
+ </details>
534
+
535
+ <br/>
536
+
537
+ #### [`isAddress`](https://essential-eth.vercel.app/docs/api/modules#isaddress)
538
+
539
+ ```typescript
540
+ isAddress(address: string): boolean
541
+ ```
542
+
543
+ <details>
544
+ <summary>View Example</summary>
545
+
546
+ ```js
547
+ import { isAddress } from 'essential-eth';
548
+ ```
549
+
550
+ ```javascript
551
+ isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
552
+ // true
553
+ ```
554
+
555
+ ```javascript
556
+ isAddress('bad');
557
+ // false
558
+ ```
559
+
560
+ ```javascript
561
+ // Does NOT support ENS.
562
+ isAddress('vitalik.eth');
563
+ // false
564
+ ```
565
+
566
+ </details>
567
+
568
+ <br/>
569
+
570
+ #### [`isBytes`](https://essential-eth.vercel.app/docs/api/modules#isbytes)
571
+
572
+ ```typescript
573
+ isBytes(value: any): value
574
+ ```
575
+
576
+ <details>
577
+ <summary>View Example</summary>
578
+
579
+ ```js
580
+ import { isBytes } from 'essential-eth';
581
+ ```
582
+
583
+ ```javascript
584
+ isBytes([1, 2, 3]);
585
+ // true
586
+ ```
587
+
588
+ ```javascript
589
+ isBytes(false);
590
+ // false
591
+ ```
592
+
593
+ ```javascript
594
+ isBytes(new Uint8Array(1));
595
+ // true
596
+ ```
597
+
598
+ </details>
599
+
600
+ <br/>
601
+
602
+ #### [`isBytesLike`](https://essential-eth.vercel.app/docs/api/modules#isbyteslike)
603
+
604
+ ```typescript
605
+ isBytesLike(value: any): value
606
+ ```
607
+
608
+ <details>
609
+ <summary>View Example</summary>
610
+
611
+ ```js
612
+ import { isBytesLike } from 'essential-eth';
613
+ ```
614
+
615
+ ```javascript
616
+ isBytesLike([1, 2, 3]);
617
+ // true
618
+ ```
619
+
620
+ ```javascript
621
+ isBytesLike(false);
622
+ // false
623
+ ```
624
+
625
+ ```javascript
626
+ isBytesLike(new Uint8Array(1));
627
+ // true
628
+ ```
629
+
630
+ </details>
631
+
632
+ <br/>
633
+
634
+ #### [`isHexString`](https://essential-eth.vercel.app/docs/api/modules#ishexstring)
635
+
636
+ ```typescript
637
+ isHexString(value: any, length: number): boolean
638
+ ```
639
+
640
+ <details>
641
+ <summary>View Example</summary>
642
+
643
+ ```js
644
+ import { isHexString } from 'essential-eth';
645
+ ```
646
+
647
+ ```javascript
648
+ isHexString('0x4924');
649
+ // true
650
+ ```
651
+
652
+ ```javascript
653
+ isHexString('0x4924', 4);
654
+ // false
655
+ // length of 4 in bytes would mean a hex string with 8 characters
656
+ ```
657
+
658
+ </details>
659
+
660
+ <br/>
661
+
662
+ #### [`jsonRpcProvider`](https://essential-eth.vercel.app/docs/api/modules#jsonrpcprovider)
663
+
664
+ ```typescript
665
+ jsonRpcProvider(rpcUrl: string): JsonRpcProvider
666
+ ```
667
+
668
+ <details>
669
+ <summary>View Example</summary>
670
+
671
+ ```js
672
+ import { jsonRpcProvider } from 'essential-eth';
673
+ ```
674
+
675
+ ```javascript
676
+ jsonRpcProvider()
677
+ .getBlock('latest')
678
+ .then((block) => {
679
+ console.log(block.number);
680
+ });
681
+ // 14530496
682
+ ```
683
+
684
+ </details>
685
+
686
+ <br/>
687
+
688
+ #### [`keccak256`](https://essential-eth.vercel.app/docs/api/modules#keccak256)
689
+
690
+ ```typescript
691
+ keccak256(data: BytesLike): string
692
+ ```
693
+
694
+ <details>
695
+ <summary>View Example</summary>
696
+
697
+ ```js
698
+ import { keccak256 } from 'essential-eth';
699
+ ```
700
+
701
+ ```javascript
702
+ keccak256('essential-eth');
703
+ // '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
704
+
705
+ keccak256('0x123');
706
+ // '0x5fa2358263196dbbf23d1ca7a509451f7a2f64c15837bfbb81298b1e3e24e4fa'
707
+ ```
708
+
709
+ </details>
710
+
711
+ <br/>
712
+
713
+ #### [`pack`](https://essential-eth.vercel.app/docs/api/modules#pack)
714
+
715
+ ```typescript
716
+ pack(types: Array<string>, values: Array<any>): string
717
+ ```
718
+
719
+ <details>
720
+ <summary>View Example</summary>
721
+
722
+ ```js
723
+ import { pack } from 'essential-eth';
724
+ ```
59
725
 
60
- // or in a non-import environment
61
- const { etherToWei } = require('essential-eth');
726
+ ```javascript
727
+ const types = ['bool', 'string', 'uint64'];
728
+ const values = [true, 'text', 30];
729
+ pack(types, values);
730
+ // '0x0174657874000000000000001e'
62
731
  ```
63
732
 
64
- - The return-type `TinyBig` is just [`Big`](https://github.com/MikeMcl/big.js) but expands scientific notation on `toNumber()` and `toString()`
733
+ </details>
65
734
 
66
- <br/>
735
+ <br/>
67
736
 
68
- #### `etherToWei`
737
+ #### [`solidityKeccak256`](https://essential-eth.vercel.app/docs/api/modules#soliditykeccak256)
69
738
 
70
739
  ```typescript
71
- // convert ether to wei
72
- etherToWei(etherQuantity: string | number | TinyBig | Big): TinyBig
740
+ solidityKeccak256(types: Array<string>, values: Array<any>): string
73
741
  ```
74
742
 
75
- <details>
743
+ <details>
76
744
  <summary>View Example</summary>
77
745
 
78
- ```typescript
79
- import { etherToWei } from 'essential-eth';
80
-
81
- etherToWei(1).toString();
82
- // "1000000000000000000"
746
+ ```js
747
+ import { solidityKeccak256 } from 'essential-eth';
748
+ ```
83
749
 
84
- etherToWei(1).toNumber();
85
- // 1000000000000000000
750
+ ```javascript
751
+ const types = ['string', 'bool', 'uint32'];
752
+ const values = ['essential-eth is great', true, 14];
753
+ solidityKeccak256(types, values);
754
+ // '0xe4d4c8e809faac09d58f468f0aeab9474fe8965d554c6c0f868c433c3fd6acab'
755
+ ```
86
756
 
87
- etherToWei('1').toNumber();
88
- // 1000000000000000000
757
+ ```javascript
758
+ const types = ['bytes4', 'uint32[5]'];
759
+ const values = [
760
+ [116, 101, 115, 116],
761
+ [5, 3, 4, 9, 18],
762
+ ];
763
+ solidityKeccak256(types, values);
764
+ // '0x038707a887f09355dc545412b058e7ba8f3c74047050c7c5e5e52eec608053d9'
89
765
  ```
90
766
 
91
- </details>
767
+ </details>
92
768
 
93
- <br/>
769
+ <br/>
94
770
 
95
- #### `weiToEther`
771
+ #### [`splitSignature`](https://essential-eth.vercel.app/docs/api/modules#splitsignature)
96
772
 
97
773
  ```typescript
98
- // convert wei to ether
99
- weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig
774
+ splitSignature(signature: SignatureLike): Signature
100
775
  ```
101
776
 
102
- <details>
777
+ <details>
103
778
  <summary>View Example</summary>
104
779
 
105
- ```typescript
106
- import { weiToEther } from 'essential-eth';
107
-
108
- weiToEther(1000000000000000000).toString();
109
- // "1"
780
+ ```js
781
+ import { splitSignature } from 'essential-eth';
782
+ ```
110
783
 
111
- weiToEther(1000000000000000000).toNumber();
112
- // 1
113
- weiToEther('1000000000000000000').toNumber();
114
- // 1
784
+ ```javascript
785
+ const signature = '0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee331b';
786
+ splitSignature(signature);
787
+ {
788
+ r: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b39716",
789
+ s: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
790
+ _vs: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
791
+ recoveryParam: 0,
792
+ v: 27,
793
+ yParityAndS: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
794
+ compact: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33"
795
+ }
115
796
  ```
116
797
 
117
- </details>
798
+ </details>
118
799
 
119
- <br/>
800
+ <br/>
120
801
 
121
- #### `gweiToEther`
802
+ #### [`stripZeros`](https://essential-eth.vercel.app/docs/api/modules#stripzeros)
122
803
 
123
804
  ```typescript
124
- gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig
805
+ stripZeros(value: BytesLike): Uint8Array
125
806
  ```
126
807
 
127
- <details>
808
+ <details>
128
809
  <summary>View Example</summary>
129
810
 
130
- ```typescript
131
- import { gweiToEther } from 'essential-eth';
132
-
133
- gweiToEther(1000000000).toString();
134
- // "1"
811
+ ```js
812
+ import { stripZeros } from 'essential-eth';
813
+ ```
135
814
 
136
- gweiToEther(1000000000).toNumber();
137
- // 1
138
- gweiToEther('1000000000').toNumber();
139
- // 1
815
+ ```javascript
816
+ stripZeros('0x00002834');
817
+ // Uint8Array { [Iterator] 0: 40, 1: 52 }
818
+ // Equivalent to '0x2834'
140
819
  ```
141
820
 
142
- </details>
821
+ </details>
143
822
 
144
- <br/>
823
+ <br/>
145
824
 
146
- #### `etherToGwei`
825
+ #### [`tinyBig`](https://essential-eth.vercel.app/docs/api/modules#tinybig)
147
826
 
148
827
  ```typescript
149
- etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig
828
+ tinyBig(value: string | number | TinyBig | Big): TinyBig
150
829
  ```
151
830
 
152
- <details>
831
+ <details>
153
832
  <summary>View Example</summary>
154
833
 
155
- ```typescript
156
- import { etherToGwei } from 'essential-eth';
157
-
158
- etherToGwei(0.000000001).toString();
159
- // "1"
834
+ ```js
835
+ import { tinyBig } from 'essential-eth';
836
+ ```
160
837
 
161
- etherToGwei(0.000000001).toNumber();
162
- // 1
163
- etherToGwei('0.000000001').toNumber();
164
- // 1
838
+ ```javascript
839
+ tinyBig(10).times(3).toNumber();
840
+ // 30
165
841
  ```
166
842
 
167
- </details>
843
+ </details>
168
844
 
169
- <br/>
845
+ <br/>
170
846
 
171
- #### `toChecksumAddress`
847
+ #### [`toChecksumAddress`](https://essential-eth.vercel.app/docs/api/modules#tochecksumaddress)
172
848
 
173
849
  ```typescript
174
- // return proper mixed-case address
175
- // does not support ICAP addresses
176
850
  toChecksumAddress(address: string): string
177
851
  ```
178
852
 
179
- <details>
853
+ <details>
180
854
  <summary>View Example</summary>
181
855
 
182
- ```typescript
856
+ ```js
183
857
  import { toChecksumAddress } from 'essential-eth';
858
+ ```
184
859
 
185
- toChecksumAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
186
- // "0xc0DEAF6bD3F0c6574a6a625EF2F22f62A5150EAB"
860
+ ```javascript
861
+ toChecksumAddress('0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359');
862
+ // '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'
187
863
  ```
188
864
 
189
- </details>
865
+ Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v5/api/utils/address/#utils-getAddress)
190
866
 
191
- <br/>
867
+ Similar to ["toChecksumAddress" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#tochecksumaddress)
868
+
869
+ </details>
192
870
 
193
- #### `isAddress`
871
+ <br/>
872
+
873
+ #### [`toUtf8Bytes`](https://essential-eth.vercel.app/docs/api/modules#toutf8bytes)
194
874
 
195
875
  ```typescript
196
- // returns boolean as to whether input is a valid address
197
- // does not support ENS nor ICAP
198
- isAddress(address: string): boolean
876
+ toUtf8Bytes(data: string): Uint8Array
199
877
  ```
200
878
 
201
- <details>
879
+ <details>
202
880
  <summary>View Example</summary>
203
881
 
204
- ```typescript
205
- import { isAddress } from 'essential-eth';
206
-
207
- isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
208
- // true
882
+ ```js
883
+ import { toUtf8Bytes } from 'essential-eth';
884
+ ```
209
885
 
210
- isAddress('bad');
211
- // false
886
+ ```javascript
887
+ toUtf8Bytes('essential-eth');
888
+ // 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 }
212
889
 
213
- // Does NOT support ENS.
214
- isAddress('vitalik.eth');
215
- // false
890
+ toUtf8Bytes('ethereum');
891
+ // Uint8Array { [Iterator] 0: 101, 1: 116, 2: 104, 3: 101, 4: 114, 5: 101, 6: 117, 7: 109 }
216
892
  ```
217
893
 
218
- </details>
894
+ </details>
219
895
 
220
- <br/>
896
+ <br/>
221
897
 
222
- #### `hexZeroPad`
898
+ #### [`weiToEther`](https://essential-eth.vercel.app/docs/api/modules#weitoether)
223
899
 
224
900
  ```typescript
225
- // returns a hex string padded to a specified length of bytes
226
- // if the hex value provided is already longer than the padding value, the value itself is returned without alteration
227
- hexZeroPad(hexValue: string | number, length: number): string
901
+ weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig
228
902
  ```
229
903
 
230
- <details>
904
+ <details>
231
905
  <summary>View Example</summary>
232
906
 
907
+ ```js
908
+ import { weiToEther } from 'essential-eth';
909
+ ```
910
+
911
+ ```javascript
912
+ weiToEther('1000000000000000000000').toString();
913
+ // '1000'
914
+ weiToEther(1000000000000000000000).toString();
915
+ // '1000'
916
+ ```
917
+
918
+ ```javascript
919
+ weiToEther('1000000000000000000000').toNumber();
920
+ // 1000
921
+ weiToEther(1000000000000000000000).toNumber();
922
+ // 1000
923
+ ```
924
+
925
+ </details>
926
+
927
+ <br/>
928
+
929
+ #### [`zeroPad`](https://essential-eth.vercel.app/docs/api/modules#zeropad)
930
+
233
931
  ```typescript
234
- import { hexZeroPad } from 'essential-eth';
932
+ zeroPad(value: BytesLike, length: number): Uint8Array
933
+ ```
235
934
 
236
- hexZeroPad('0x60', 2);
237
- // '0x0060'
935
+ <details>
936
+ <summary>View Example</summary>
238
937
 
239
- hexZeroPad(0x60, 3);
240
- // '0x000060'
938
+ ```js
939
+ import { zeroPad } from 'essential-eth';
940
+ ```
241
941
 
242
- // Length of string is already longer than padding value
243
- hexZeroPad('0x31323334', 3);
244
- // Throws error
942
+ ```javascript
943
+ zeroPad('0x039284');
944
+ // Uint8Array { [Iterator] 0: 0, 1: 0, 2: 0, 3: 3, 4: 146, 5: 132 }
945
+ // Equivalent to 0x000000039284
245
946
  ```
246
947
 
247
- </details>
948
+ ```javascript
949
+ zeroPad([39, 25, 103, 45], 5);
950
+ // Uint8Array { [Iterator] 0: 0, 1: 39, 2: 25, 3: 103, 4: 45 }
951
+ ```
952
+
953
+ </details>
954
+
955
+ <br/>
956
+
957
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
958
+
959
+ - _The return-type `TinyBig` is just [`Big`](https://github.com/MikeMcl/big.js) but expands scientific notation on `toNumber()` and `toString()`_
248
960
 
961
+ <br/>
249
962
  <br/>
250
963
 
251
- ## RPC
964
+ ## Providers
252
965
 
253
966
  ```typescript
254
967
  import { JsonRpcProvider } from 'essential-eth';
255
- const essentialEth = new JsonRpcProvider(
256
- 'RPC URL HERE' /* Try POKT or Infura */,
257
- );
968
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try POKT or Infura */);
258
969
  // OR for very quick testing (limited to 10,000 requests)
259
- const essentialEth = new JsonRpcProvider();
970
+ const provider = new JsonRpcProvider();
260
971
  ```
261
972
 
262
973
  <details>
@@ -282,294 +993,445 @@ provider.getGasPrice().toNumber();
282
993
 
283
994
  <br/>
284
995
 
285
- #### [`getTransactionCount(address, blockTag?): Promise<number>`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#gettransactioncount)
286
-
287
- #### `getGasPrice`
996
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:START (PROVIDER) -->
288
997
 
289
- Returns the current gas price in gwei
998
+ #### [`call`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#call)
290
999
 
291
1000
  ```typescript
292
- // Same as ethers.providers.getGasPrice
293
- getGasPrice(): Promise<TinyBig>
1001
+ provider.call(transaction: TransactionRequest, blockTag?: BlockTag): Promise<string>
294
1002
  ```
295
1003
 
296
- <details>
1004
+ <details>
297
1005
  <summary>View Example</summary>
298
1006
 
299
- ```typescript
1007
+ ```js
300
1008
  import { JsonRpcProvider } from 'essential-eth';
301
-
302
- const provider = new JsonRpcProvider('https://free-eth-node.com/api/eth');
303
- provider.getGasPrice().toNumber();
304
- /*
305
- 39695942769
306
- */
1009
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
307
1010
  ```
308
1011
 
309
- </details>
1012
+ ```javascript
1013
+ await provider.call({
1014
+ to: '0x6b175474e89094c44da98b954eedeac495271d0f',
1015
+ data: '0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE',
1016
+ });
1017
+ // '0x0000000000000000000000000000000000000000000000000858898f93629000'
1018
+ ```
310
1019
 
311
- <br/>
1020
+ </details>
312
1021
 
313
- #### `getBalance`
1022
+ <br/>
314
1023
 
315
- Returns the balance of an address at a given block
1024
+ #### [`estimateGas`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#estimategas)
316
1025
 
317
1026
  ```typescript
318
- // Same API as ethers.providers.getBalance
319
- // Same API as web3.eth.getBalance
320
- getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>
1027
+ provider.estimateGas(transaction: TransactionRequest): Promise<TinyBig>
321
1028
  ```
322
1029
 
323
- <details>
1030
+ <details>
324
1031
  <summary>View Example</summary>
325
1032
 
1033
+ ```js
1034
+ import { JsonRpcProvider } from 'essential-eth';
1035
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1036
+ ```
1037
+
1038
+ ```javascript
1039
+ await provider.estimateGas({
1040
+ // Wrapped ETH address
1041
+ to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1042
+ data: '0xd0e30db0',
1043
+ value: etherToWei('1.0').toHexString(),
1044
+ });
1045
+ // { TinyBig: "27938" }
1046
+ ```
1047
+
1048
+ </details>
1049
+
1050
+ <br/>
1051
+
1052
+ #### [`getBalance`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getbalance)
1053
+
326
1054
  ```typescript
1055
+ provider.getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>
1056
+ ```
1057
+
1058
+ <details>
1059
+ <summary>View Example</summary>
1060
+
1061
+ ```js
327
1062
  import { JsonRpcProvider } from 'essential-eth';
1063
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1064
+ ```
328
1065
 
329
- const provider = new JsonRpcProvider();
330
- await provider
331
- .getBalance('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8')
332
- .then((balance) => console.log(balance.toString()));
333
- // "28798127851528138"
1066
+ ```javascript
1067
+ await provider.getBalance('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8');
1068
+ // 28798127851528138
334
1069
  ```
335
1070
 
336
- </details>
1071
+ </details>
337
1072
 
338
- <br/>
1073
+ <br/>
339
1074
 
340
- #### `getNetwork`
1075
+ #### [`getBlock`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getblock)
341
1076
 
342
- Returns a Network
1077
+ ```typescript
1078
+ provider.getBlock(timeFrame?: BlockTag, returnTransactionObjects?: boolean): Promise<BlockResponse>
1079
+ ```
1080
+
1081
+ <details>
1082
+ <summary>View Example</summary>
1083
+
1084
+ ```js
1085
+ import { JsonRpcProvider } from 'essential-eth';
1086
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1087
+ ```
1088
+
1089
+ ```javascript
1090
+ await provider.getBlock(14879862);
1091
+ // {
1092
+ // baseFeePerGas: { TinyBig: 39095728776 },
1093
+ // difficulty: { TinyBig: 14321294455359973 },
1094
+ // extraData: "0x486976656f6e2073672d6865617679",
1095
+ // gasLimit: { TinyBig: 29970620 },
1096
+ // gasUsed: { TinyBig: 20951384 },
1097
+ // hash: "0x563b458ec3c4f87393b53f70bdddc0058497109b784d8cacd9247ddf267049ab",
1098
+ // logsBloom:
1099
+ // "0x9f38794fe80b521794df6efad8b0d2e9582f9ec3959a3f9384bda0fa371cfa5fac5af9d515c6bdf1ec325f5b5f7ebdd6a3a9fae17b38a86d4dc4b0971afc68d8086640550f4c156e6f923f4a1bb94fb0bed6cdcc474c5c64bfeff7a4a906f72b9a7b94004ee58efc53d63ac66961acd3a431b2d896cc9fd75f6072960bced45f770587caf130f57504decfcb63c6ca8fbc5bdbd749edd5a99a7375d2b81872289adb775fb3c928259f4be39c6d3f4d5b6217822979bb88c1f1fb62429b1b6d41cf4e3f77f9e1db3f5723108f1e5b1255dd734ad8cdb11e7ea22487c788e67c83777b6f395e504ca59c64f52245ee6de3804cf809e5caa4f0ea6a9aa9eb6ed801",
1100
+ // miner: "0x1aD91ee08f21bE3dE0BA2ba6918E714dA6B45836",
1101
+ // mixHash: "0x73cc9419bfb89c9d41c3a8c34ce56b5ebe468bdcf870258d2e77262275d580ec",
1102
+ // nonce: "0x976f3f5d596ffb08",
1103
+ // number: 14879862,
1104
+ // parentHash: "0x95986ae14a71face8d9a6a379edd875b2e8bc73e4de0d9d460e7752bddb0f579",
1105
+ // receiptsRoot: "0x8e6ba2fd9bee602b653dae6e3132f16538c2c5df24f1df8c000392053f73defa",
1106
+ // sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
1107
+ // size: { TinyBig: 134483 },
1108
+ // stateRoot: "0xbf2bb67bd1c741f3d00904b8451d7c2cf4e3a2726f5a5884792ede2074747b85",
1109
+ // timestamp: { TinyBig: 1654016186 },
1110
+ // totalDifficulty: { TinyBig: 50478104614257705213748 },
1111
+ // transactions: [
1112
+ // "0xb3326a9149809603a2c28545e50e4f7d16e194bf5ee9764e0544603854c4a8d2",
1113
+ // "0x8b42095f8d335404a4896b2817b8e5e3d86a5a87cb434a8eec295d5280a7f48e",
1114
+ // "0x882f78fcb73f0f7ad0700bb0424a8b4beb366aaa93b88a3562c49a8d0ce4dcff",
1115
+ // ...
1116
+ // ],
1117
+ // transactionsRoot: "0x5934902f3dcc263ec34f24318179bf6301f53f4834685792066026f3a4849d72",
1118
+ // uncles: [],
1119
+ // }
1120
+ ```
1121
+
1122
+ </details>
1123
+
1124
+ <br/>
1125
+
1126
+ #### [`getBlockNumber`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getblocknumber)
343
1127
 
344
1128
  ```typescript
345
- // Same API as ethers.providers.getNetwork
346
- getNetwork(): Promise<Network>
1129
+ provider.getBlockNumber(): Promise<number>
347
1130
  ```
348
1131
 
349
- <details>
1132
+ <details>
350
1133
  <summary>View Example</summary>
351
1134
 
1135
+ ```js
1136
+ import { JsonRpcProvider } from 'essential-eth';
1137
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1138
+ ```
1139
+
1140
+ ```javascript
1141
+ await provider.getBlockNumber();
1142
+ // 1053312
1143
+ ```
1144
+
1145
+ </details>
1146
+
1147
+ <br/>
1148
+
1149
+ #### [`getCode`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getcode)
1150
+
352
1151
  ```typescript
1152
+ provider.getCode(address: string, blockTag?: BlockTag): Promise<string>
1153
+ ```
1154
+
1155
+ <details>
1156
+ <summary>View Example</summary>
1157
+
1158
+ ```js
353
1159
  import { JsonRpcProvider } from 'essential-eth';
1160
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1161
+ ```
354
1162
 
355
- const maticProvider = new JsonRpcProvider(
356
- 'https://free-eth-node.com/api/matic',
1163
+ ```javascript
1164
+ await jsonRpcProvider().getCode(
1165
+ '0xaC6095720221C79C6E7C638d260A2eFBC5D8d880',
1166
+ 'latest',
357
1167
  );
358
- maticProvider.getNetwork();
359
- /*
360
- { chainId: 137, name: 'MATIC', ensAddress: null }
361
- */
1168
+ // '0x608060405234801561001057600080fd5b506004361061...'
1169
+ ```
362
1170
 
363
- const xdaiProvider = new JsonRpcProvider('https://free-eth-node.com/api/xdai');
364
- xdaiProvider.getNetwork();
365
- /*
366
- { chainId: 100, name: 'xdai', ensAddress: null } }
367
- */
1171
+ </details>
1172
+
1173
+ <br/>
1174
+
1175
+ #### [`getGasPrice`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getgasprice)
1176
+
1177
+ ```typescript
1178
+ provider.getGasPrice(): Promise<TinyBig>
368
1179
  ```
369
1180
 
370
- </details>
1181
+ <details>
1182
+ <summary>View Example</summary>
371
1183
 
372
- <br/>
1184
+ ```js
1185
+ import { JsonRpcProvider } from 'essential-eth';
1186
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1187
+ ```
1188
+
1189
+ ```javascript
1190
+ await provider.getGasPrice();
1191
+ // 52493941856
1192
+ ```
1193
+
1194
+ </details>
373
1195
 
374
- #### `getBlock`
1196
+ <br/>
375
1197
 
376
- Returns a Block
1198
+ #### [`getLogs`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getlogs)
377
1199
 
378
1200
  ```typescript
379
- // Same API as web3.eth.getBlock
380
- getBlock(timeFrame: number | "latest" | "earliest" | "pending", returnTransactionObjects?: boolean): Promise<Block>
1201
+ provider.getLogs(filter: Filter | FilterByBlockHash): Promise<Array<Log>>
381
1202
  ```
382
1203
 
383
- <details>
1204
+ <details>
384
1205
  <summary>View Example</summary>
385
1206
 
1207
+ ```js
1208
+ import { JsonRpcProvider } from 'essential-eth';
1209
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1210
+ ```
1211
+
1212
+ ```javascript
1213
+ provider.getLogs({
1214
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1215
+ topics: [
1216
+ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
1217
+ '0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
1218
+ ],
1219
+ fromBlock: 14825027,
1220
+ toBlock: 14825039,
1221
+ });
1222
+
1223
+ [
1224
+ {
1225
+ address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1226
+ blockHash:
1227
+ '0x8e0dfac2f704851960f866c8708b3bef2f66c0fee0329cf25ff0261b264ca6bc',
1228
+ blockNumber: 14825029,
1229
+ data: '0x000000000000000000000000000000000000000000000000005f862ee352a38a',
1230
+ logIndex: 384,
1231
+ removed: false,
1232
+ topics: [
1233
+ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
1234
+ '0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
1235
+ '0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45',
1236
+ ],
1237
+ transactionHash:
1238
+ '0xbd49031be16f8fd1775f4e0fe79b408ffd8ae9c65b2827ee47e3238e3f51f4c0',
1239
+ transactionIndex: 226,
1240
+ },
1241
+ ];
1242
+ ```
1243
+
1244
+ </details>
1245
+
1246
+ <br/>
1247
+
1248
+ #### [`getNetwork`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#getnetwork)
1249
+
386
1250
  ```typescript
1251
+ provider.getNetwork(): Promise<Network>
1252
+ ```
1253
+
1254
+ <details>
1255
+ <summary>View Example</summary>
1256
+
1257
+ ```js
387
1258
  import { JsonRpcProvider } from 'essential-eth';
388
- const essentialEth = new JsonRpcProvider();
389
- essentialEth.getBlock('latest');
1259
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1260
+ ```
390
1261
 
391
- /*
392
- {
393
- number: 4232826,
394
- hash: '0x93211a1cd17e154b183565ec685254a03f844a8e34824a46ce1bdd6753dcb669',
395
- parentHash: '0x1b32bfcba1bb2a57f56e166a3bb06875a1978992999dfc8828397b4c1526f472',
396
- sha3Uncles: '0x0fb399c67bb5a071ec8a22549223215ab76b7d4009941c9c37aa3c3936010463',
397
- logsBloom: '0x00000000000000000000101000000000020000000000000000000000000000000000400000010000000000000000000000000000010000000008800000000800000000200000000000000000000000000000000000000000000002000000000000000000000000000040000000000040000000000000000000000000000000000000000000000001000000000004000000000010000000000000000020000000000000000200100020000000000000000080000000000080001000000000000000000001040000000000000000008000000020010100000000200000100000000000000000000000002000000080000000020400000000002000200000000000',
398
- transactionsRoot: '0xc43b3f13e1fe810e34d3a26ffe465b72c7063a5c70a02de2c78e91e4d10bd9fb',
399
- stateRoot: '0x04d7bc816537ea7ef3a16e76c9879d29f34f99d4154273c2e98e012a31bad745',
400
- receiptsRoot: '0x89c6f781ceac0bd49c4d9aa9115df4a5d4dd0e0220ff7668012f15bc04222c6b',
401
- miner: '0x31fe561eb2c628cD32Ec52573D7c4b7E4C278Bfa',
402
- difficulty: '1300907486001755331049',
403
- totalDifficulty: '5989929395521171616186006183',
404
- extraData: '0xce018c495249532d62613031656132',
405
- size: 5416,
406
- gasLimit: 6800000,
407
- gasUsed: 202955,
408
- timestamp: 1649884910,
409
- transactions: [
410
- '0x6b34a59c7b9aead24fa6dad782f8a3ad84ed4a23ee09bcbf0bcf880840fbbe20',
411
- '0x9a3851ca24d5336c6a0d48aba2c4b4769d7a672c9b01729c5eb9924efd1b19a7',
412
- '0xc3ed3d198b62f2f3427ebfa3bbd0fcada4e3c0c189e4464e7eeceb403c75981e'
413
- ],
414
- uncles: [
415
- '0x0c567c054e98153f10d651fbbc018891c1dd9d62a9ffd998e87678803e95b6ed',
416
- '0xb7d69389dbfb057c6fcb4bc0582d46a2ba01170703f0dadf8cd1462b83e88753',
417
- '0xd5f74ccd0ad4c58b3161e8c2c507c264231e5f28925061b809c02e5e4bb6db28'
418
- ],
419
- minimumGasPrice: '0x387ee40',
420
- bitcoinMergedMiningHeader: '0x04000020e8567ed3d2480e15a1dd1b4335e4732ae343c037e4fd03000000000000000000ed10a8340d163d3e813bdd430f902f4e5a56828dc62313b2e23797c0be6b8516eb3e576297d8091735884f42',
421
- bitcoinMergedMiningCoinbaseTransaction: '0x0000000000000140e910128fda7bac502dc5e0573bbaf12de8e2524f70c22f7bd160dedcb19a2521002b6a2952534b424c4f434b3ae493303f597fa368c0ccc4f8aceabf1c315bb7c9a07605c073a89f260040967aace6a7d9',
422
- bitcoinMergedMiningMerkleProof: '0xdf63a3d7eb6fbcfb301311faa46e9a15b0408bb1a04e284daee86c273c1dfd65ede23f3170f806e9e0f4cef7ba6b56aa37470d9c23f96ec8e43d08b58645919c5e10bcb892897a731f8f9ce79c72dc0e390896bcd6c67bb38c0bdb72982b6cf05519968d76673572c3f3ef3a08b0ddb464863f1788f7cdbaad3fe44a8a8af576d430ac282fe28852c16df198ca96cc5f71a50695912efe1a836e8442be69e31b6d6f973da2818bce9a3a1c2d9be0671aee9a7776e398d6a03d1e178e20d84646004a3d03c0501334e629d9146aa6a01316dcbaa289df6e6c5e3090cadaddff22699cfc7ff09512fc0d65c5062f17c98561ce3c9510de210d9d654cf99f8d756ff37c9fa21e7122ee8cadb923341690845d572921425f2bd7e044558b7e07983ac4df28928028b0c13c3624dc7a965af8091b0cecc845bf7da5308c03b2c97d607f6706a599f802025894435f1d76ea4e67cc2fc4e1559f1206f559a24633de0f',
423
- hashForMergedMining: '0xe493303f597fa368c0ccc4f8aceabf1c315bb7c9a07605c073a89f260040967a',
424
- paidFees: '0xc0744dcb7a0',
425
- cumulativeDifficulty: '0x1190930db285269e582'
426
- }
427
- */
1262
+ ```javascript
1263
+ jsonRpcProvider('https://free-eth-node.com/api/eth').getNetwork();
1264
+ // { chainId: 1, name: 'eth', ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' }
428
1265
  ```
429
1266
 
430
- </details>
1267
+ ```javascript
1268
+ jsonRpcProvider('https://free-eth-node.com/api/MATIC').getNetwork();
1269
+ // { chainId: 137, name: 'MATIC', ensAddress: null }
1270
+ ```
431
1271
 
432
- <br/>
1272
+ </details>
433
1273
 
434
- #### `getTransaction`
1274
+ <br/>
435
1275
 
436
- Returns the Transaction associated with a given hash
1276
+ #### [`getTransaction`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#gettransaction)
437
1277
 
438
1278
  ```typescript
439
- // Similar to ethers.provider.getTransaction, formatting may differ
440
- getTransaction(hash: string): Promise<Transaction>
1279
+ provider.getTransaction(transactionHash: string): Promise<TransactionResponse>
441
1280
  ```
442
1281
 
443
- <details>
1282
+ <details>
444
1283
  <summary>View Example</summary>
445
1284
 
446
- ```typescript
1285
+ ```js
447
1286
  import { JsonRpcProvider } from 'essential-eth';
448
- const essentialEth = new JsonRpcProvider();
1287
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1288
+ ```
1289
+
1290
+ ```javascript
449
1291
  await provider.getTransaction(
450
1292
  '0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789',
451
1293
  );
1294
+ // {
1295
+ // accessList: [],
1296
+ // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1297
+ // blockNumber: 14578286,
1298
+ // chainId: 1,
1299
+ // from: "0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4",
1300
+ // gas: { TinyBig: 112163 },
1301
+ // gasPrice: { TinyBig: 48592426858 },
1302
+ // hash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1303
+ // input: "0x83259f17000000000000000000000000000000000000000000...",
1304
+ // maxFeePerGas: { TinyBig: 67681261618 },
1305
+ // maxPriorityFeePerGas: { TinyBig: 1500000000 },
1306
+ // nonce: { TinyBig: 129 },
1307
+ // r: "0x59a7c15b12c18cd68d6c440963d959bff3e73831ffc938e75ecad07f7ee43fbc",
1308
+ // s: "0x1ebaf05f0d9273b16c2a7748b150a79d22533a8cd74552611cbe620fee3dcf1c",
1309
+ // to: "0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B",
1310
+ // transactionIndex: 29,
1311
+ // type: 2,
1312
+ // v: 0,
1313
+ // value: { TinyBig: 0 },
1314
+ // confirmations: 298140,
1315
+ // }
1316
+ ```
452
1317
 
453
- /*
454
- {
455
- accessList: [],
456
- blockHash: '0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d',
457
- blockNumber: 14578286,
458
- chainId: 1,
459
- from: '0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4',
460
- gas: Big {
461
- s: 1,
462
- e: 5,
463
- c: [ 1, 1, 2, 1, 6, 3 ],
464
- constructor: <ref *1> [Function: Big] {
465
- DP: 20,
466
- RM: 1,
467
- NE: -7,
468
- PE: 21,
469
- strict: false,
470
- roundDown: 0,
471
- roundHalfUp: 1,
472
- roundHalfEven: 2,
473
- roundUp: 3,
474
- Big: [Circular *1],
475
- default: [Circular *1]
476
- }
477
- },
478
- gasPrice: Big {
479
- s: 1,
480
- e: 10,
481
- c: [
482
- 4, 8, 5, 9, 2,
483
- 4, 2, 6, 8, 5,
484
- 8
485
- ],
486
- constructor: <ref *1> [Function: Big] {
487
- DP: 20,
488
- RM: 1,
489
- NE: -7,
490
- PE: 21,
491
- strict: false,
492
- roundDown: 0,
493
- roundHalfUp: 1,
494
- roundHalfEven: 2,
495
- roundUp: 3,
496
- Big: [Circular *1],
497
- default: [Circular *1]
498
- }
499
- },
500
- hash: '0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789',
501
- input: '0x83259f170000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000009e99ad11a214fd016b19dc3648678c5944859ae292b21c24ca94f857836c4596f1950c82dd0c23dd621af4763edc2f66466e63c5df9de0c1107b1cd16bf460fe93e43fd308e3444bc79c3d88a4cb961dc8367ab6ad048867afc76d193bca99cf3a068864ed4a7df1dbf1d4c52238eced3e5e05644b4040fc2b3ccb8557b0e99fff6131305a0ea2b8061b90bd418db5bbdd2e92129f52d93f90531465e309c4caec5b85285822b6196398d36f16f511811b61bbda6461e80e29210cd303118bdcee8df6fa0505ffbe8642094fd2ba4dd458496fe3b459ac880bbf71877c713e969ccf5ed7efab8a84ebc07e3939901371ca427e1192e455a8f35a6a1d7ad09e1475dd1758b36fa631dab5d70e99316b23c4c43094188d360cd9c3457355904e07c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000162074a7047f',
502
- maxFeePerGas: Big {
503
- s: 1,
504
- e: 10,
505
- c: [
506
- 6, 7, 6, 8, 1,
507
- 2, 6, 1, 6, 1,
508
- 8
509
- ],
510
- constructor: <ref *1> [Function: Big] {
511
- DP: 20,
512
- RM: 1,
513
- NE: -7,
514
- PE: 21,
515
- strict: false,
516
- roundDown: 0,
517
- roundHalfUp: 1,
518
- roundHalfEven: 2,
519
- roundUp: 3,
520
- Big: [Circular *1],
521
- default: [Circular *1]
522
- }
523
- },
524
- maxPriorityFeePerGas: Big {
525
- s: 1,
526
- e: 9,
527
- c: [ 1, 5 ],
528
- constructor: <ref *1> [Function: Big] {
529
- DP: 20,
530
- RM: 1,
531
- NE: -7,
532
- PE: 21,
533
- strict: false,
534
- roundDown: 0,
535
- roundHalfUp: 1,
536
- roundHalfEven: 2,
537
- roundUp: 3,
538
- Big: [Circular *1],
539
- default: [Circular *1]
540
- }
541
- },
542
- nonce: 129,
543
- r: '0x59a7c15b12c18cd68d6c440963d959bff3e73831ffc938e75ecad07f7ee43fbc',
544
- s: '0x1ebaf05f0d9273b16c2a7748b150a79d22533a8cd74552611cbe620fee3dcf1c',
545
- to: '0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B',
546
- transactionIndex: 29,
547
- type: 2,
548
- v: 0,
549
- value: Big {
550
- s: 1,
551
- e: 0,
552
- c: [ 0 ],
553
- constructor: <ref *1> [Function: Big] {
554
- DP: 20,
555
- RM: 1,
556
- NE: -7,
557
- PE: 21,
558
- strict: false,
559
- roundDown: 0,
560
- roundHalfUp: 1,
561
- roundHalfEven: 2,
562
- roundUp: 3,
563
- Big: [Circular *1],
564
- default: [Circular *1]
565
- }
566
- },
567
- confirmations: 1210
568
- }
569
- */
1318
+ </details>
1319
+
1320
+ <br/>
1321
+
1322
+ #### [`getTransactionCount`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#gettransactioncount)
1323
+
1324
+ ```typescript
1325
+ provider.getTransactionCount(address: string, blockTag?: BlockTag): Promise<number>
570
1326
  ```
571
1327
 
572
- </details>
1328
+ <details>
1329
+ <summary>View Example</summary>
1330
+
1331
+ ```js
1332
+ import { JsonRpcProvider } from 'essential-eth';
1333
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1334
+ ```
1335
+
1336
+ ```javascript
1337
+ await provider.getTransactionCount(
1338
+ '0x71660c4005ba85c37ccec55d0c4493e66fe775d3',
1339
+ );
1340
+ // 1060000
1341
+ ```
1342
+
1343
+ ```javascript
1344
+ await provider.getTransactionCount(
1345
+ '0x71660c4005ba85c37ccec55d0c4493e66fe775d3',
1346
+ 'latest',
1347
+ );
1348
+ // 1060000
1349
+ ```
1350
+
1351
+ ```javascript
1352
+ await provider.getTransactionCount(
1353
+ '0x71660c4005ba85c37ccec55d0c4493e66fe775d3',
1354
+ 14649390,
1355
+ );
1356
+ // 1053312
1357
+ ```
1358
+
1359
+ </details>
1360
+
1361
+ <br/>
1362
+
1363
+ #### [`getTransactionReceipt`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#gettransactionreceipt)
1364
+
1365
+ ```typescript
1366
+ provider.getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>
1367
+ ```
1368
+
1369
+ <details>
1370
+ <summary>View Example</summary>
1371
+
1372
+ ```js
1373
+ import { JsonRpcProvider } from 'essential-eth';
1374
+ const provider = new JsonRpcProvider('RPC URL HERE' /* Try Infura or POKT */);
1375
+ ```
1376
+
1377
+ ```javascript
1378
+ await provider.getTransactionReceipt(
1379
+ '0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789',
1380
+ );
1381
+ // {
1382
+ // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1383
+ // blockNumber: 14578286,
1384
+ // contractAddress: null,
1385
+ // cumulativeGasUsed: { TinyBig: 3067973 },
1386
+ // effectiveGasPrice: { TinyBig: 48592426858 },
1387
+ // from: "0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4",
1388
+ // gasUsed: { TinyBig: 112163 },
1389
+ // logs: [
1390
+ // {
1391
+ // address: "0x0eDF9bc41Bbc1354c70e2107F80C42caE7FBBcA8",
1392
+ // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1393
+ // blockNumber: 14578286,
1394
+ // data: "0x0000000000000000000000000000000000000000000003a12ec797b5484968c1",
1395
+ // logIndex: 42,
1396
+ // topics: [
1397
+ // "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
1398
+ // "0x00000000000000000000000039b72d136ba3e4cef35f48cd09587ffab754dd8b",
1399
+ // "0x000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed4",
1400
+ // ],
1401
+ // transactionHash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1402
+ // transactionIndex: 29,
1403
+ // },
1404
+ // {
1405
+ // address: "0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B",
1406
+ // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1407
+ // blockNumber: 14578286,
1408
+ // data: "0x0000000000000000000000000000000000000000000003a12ec797b5484968c1",
1409
+ // logIndex: 43,
1410
+ // topics: [
1411
+ // "0x34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7",
1412
+ // "0x000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed4",
1413
+ // "0x0000000000000000000000000000000000000000000000000000000000000003",
1414
+ // ],
1415
+ // transactionHash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1416
+ // transactionIndex: 29,
1417
+ // },
1418
+ // ],
1419
+ // logsBloom: "0x00000000000000000000000000000...",
1420
+ // status: 1,
1421
+ // to: "0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B",
1422
+ // transactionHash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1423
+ // transactionIndex: 29,
1424
+ // type: 2,
1425
+ // byzantium: true,
1426
+ // confirmations: 298171,
1427
+ // }
1428
+ ```
1429
+
1430
+ </details>
1431
+
1432
+ <br/>
1433
+
1434
+ <!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
573
1435
 
574
1436
  <br/>
575
1437
 
@@ -577,7 +1439,7 @@ await provider.getTransaction(
577
1439
 
578
1440
  ⚠️ Only read functions are currently supported. ⚠️
579
1441
 
580
- - 🧪 This is **highly experimental**, do not use this in production yet. (even though [earni.fi](https://earni.fi) does)
1442
+ - 🧪 `Contract` support is **experimental**, do not use this in production yet. (even though [earni.fi](https://earni.fi) does)
581
1443
 
582
1444
  Encoding support:
583
1445
 
@@ -593,7 +1455,7 @@ Decoding support:
593
1455
  - `bytes32`
594
1456
  - `uint8`
595
1457
 
596
- _Assume any smart-contract method outside the above types will break_
1458
+ _Assume all types outside the above types will break for now_
597
1459
 
598
1460
  ```typescript
599
1461
  import { Contract, jsonRpcProvider, JSONABI } from 'essential-eth';
@@ -654,5 +1516,17 @@ Any function on a contract. Returns are the same as `ethers.js`, except that ins
654
1516
 
655
1517
  <br/>
656
1518
 
1519
+ ### Identical vs Similar vs Dissimliar {#isd}
1520
+
1521
+ Throughout the documentation for `essential-eth`, you may notice that some functions are compared to `ethers.js` and `web3.js`. The keywords `identical`, `similar`, and `dissimilar` are used to help you migrate to `essential-eth`. Here's a guide on what these keywords mean:
1522
+
1523
+ - Identical -- should behave exactly like the library you're already using, except the types might be different (`TinyBig` vs [`Bn.js`](https://github.com/indutny/bn.js)).
1524
+ - Similar -- can probably be used as a replacement to the library you're currently using, except there are some differences. Read the notes next to this keyword to see why these aren't considered `identical`.
1525
+ - Dissimilar -- _should not_ be used in place of the function you're currently using. Read the notes next to this keyword to see why these functions aren't considered `similar`, and potentially learn how to alter your implementation to make `essential-eth` work for you.
1526
+
1527
+ Note: In `web3.js`, almost every method or function can be passed a callback. `essential-eth`, like `ethers.js`, does not include this functionality and trusts that users will rely on the much more modern [promise](https://javascript.info/promise-basics) and [async/await](https://javascript.info/async-await) patterns.
1528
+
1529
+ ### Miscellaneous
1530
+
657
1531
  - [📓 View full docs](https://essential-eth.vercel.app)
658
1532
  - [📓 View changelog (by looking at releases diff)](https://github.com/dawsbot/essential-eth/releases)