|
9 | 9 | | Implements schema and functions related to Ethereum's block. |
|
10 | 10 | | ------------------------------------------------------------ |
|
11 | 11 |
|
12 |
| -Note: this `README` reflects the state of the library from `v3.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-block) for an introduction on the last preceding release. |
13 | 12 |
|
14 | 13 | ## Installation
|
15 | 14 |
|
16 |
| -To obtain the latest version, simply require the project using `npm`: |
| 15 | +To obtain the latest version, simply install the project using `npm`: |
17 | 16 |
|
18 | 17 | ```shell
|
19 | 18 | npm install @ethereumjs/block
|
20 | 19 | ```
|
21 | 20 |
|
22 |
| -**Note:** If you want to work with `EIP-4844` related functionality, you will have additional manual installation steps for the **KZG setup**, see related section below. |
| 21 | +**Note:** If you want to work with `EIP-4844` related functionality, you will have additional initialization steps for the **KZG setup**, see related section below. |
23 | 22 |
|
24 | 23 | ## Usage
|
25 | 24 |
|
26 | 25 | ### Introduction
|
27 | 26 |
|
28 |
| -There are five standalone functions to instantiate a `Block`: |
| 27 | +There are several standalone functions to instantiate a `Block`: |
29 | 28 |
|
30 | 29 | - `createBlock(blockData: BlockData = {}, opts?: BlockOptions)`
|
31 |
| -- `createBlockFromRLPSerializedBlock(serialized: Uint8Array, opts?: BlockOptions)` |
| 30 | +- `createEmptyBlock(headerData: HeaderData, opts?: BlockOptions)` |
32 | 31 | - `createBlockFromBytesArray(values: BlockBytes, opts?: BlockOptions)`
|
33 |
| -- `createBlockFromRPC(blockParams: JsonRpcBlock, uncles?: any[], opts?: BlockOptions)` |
34 |
| -- `createBlockFromJsonRPCProvider(provider: string | EthersProvider, blockTag: string | bigint, opts: BlockOptions)` |
| 32 | +- `createBlockFromRLP(serialized: Uint8Array, opts?: BlockOptions)` |
| 33 | +- `createBlockFromRPC(blockParams: JSONRPCBlock, uncles?: any[], opts?: BlockOptions)` |
| 34 | +- `createBlockFromJSONRPCProvider(provider: string | EthersProvider, blockTag: string | bigint, opts: BlockOptions)` |
| 35 | +- `createBlockFromExecutionPayload(payload: ExecutionPayload, opts?: BlockOptions)` |
| 36 | +- `createBlockFromBeaconPayloadJSON(payload: BeaconPayloadJSON, opts?: BlockOptions)` |
| 37 | +- `createSealedCliqueBlock(blockData: BlockData = {}, cliqueSigner: Uint8Array, opts?: BlockOptions)` |
35 | 38 |
|
36 |
| -For `BlockHeader` instantiation standalone functions exists for instantiation, see API docs linked below. |
| 39 | +For `BlockHeader` instantiation, there are similar standalone functions: |
| 40 | + |
| 41 | +- `createBlockHeader(headerData: HeaderData = {}, opts?: BlockOptions)` |
| 42 | +- `createBlockHeaderFromBytesArray(values: BlockHeaderBytes, opts?: BlockOptions)` |
| 43 | +- `createBlockHeaderFromRLP(serializedHeaderData: Uint8Array, opts?: BlockOptions)` |
| 44 | +- `createBlockHeaderFromRPC(blockParams: JSONRPCBlock, options?: BlockOptions)` |
| 45 | +- `createSealedCliqueBlockHeader(headerData: HeaderData = {}, cliqueSigner: Uint8Array, opts?: BlockOptions)` |
37 | 46 |
|
38 | 47 | Instantiation Example:
|
39 | 48 |
|
@@ -449,7 +458,7 @@ console.log(`Old Clique Proof-of-Authority block created`)
|
449 | 458 | For sealing a block on instantiation you can use the `cliqueSigner` constructor option:
|
450 | 459 |
|
451 | 460 | ```ts
|
452 |
| -const cliqueSigner = Buffer.from('PRIVATE_KEY_HEX_STRING', 'hex') |
| 461 | +const cliqueSigner = hexToBytes('PRIVATE_KEY_HEX_STRING') |
453 | 462 | const block = createSealedCliqueBlock(blockData, cliqueSigner)
|
454 | 463 | ```
|
455 | 464 |
|
@@ -519,17 +528,6 @@ const { EthereumJSClass } = require('@ethereumjs/[PACKAGE_NAME]')
|
519 | 528 |
|
520 | 529 | Using ESM will give you additional advantages over CJS beyond browser usage like static code analysis / Tree Shaking which CJS can not provide.
|
521 | 530 |
|
522 |
| -### Buffer -> Uint8Array |
523 |
| - |
524 |
| -With the breaking releases from Summer 2023 we have removed all Node.js specific `Buffer` usages from our libraries and replace these with [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) representations, which are available both in Node.js and the browser (`Buffer` is a subclass of `Uint8Array`). |
525 |
| - |
526 |
| -We have converted existing Buffer conversion methods to Uint8Array conversion methods in the [@ethereumjs/util](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/util) `bytes` module, see the respective README section for guidance. |
527 |
| - |
528 |
| -### BigInt Support |
529 |
| - |
530 |
| -Starting with v4 the usage of [BN.js](https://github.com/indutny/bn.js/) for big numbers has been removed from the library and replaced with the usage of the native JS [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) data type (introduced in `ES2020`). |
531 |
| - |
532 |
| -Please note that number-related API signatures have changed along with this version update and the minimal build target has been updated to `ES2020`. |
533 | 531 |
|
534 | 532 | ## Testing
|
535 | 533 |
|
|
0 commit comments