You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package is currently in early alpha and is a work in progress. It is not intended for use in production environments, but rather for research and development purposes. Any help in improving the package is very much welcome.
15
15
16
+
## Table of Contents
17
+
18
+
-[Installation](#installation)
19
+
-[EthereumJS](#ethereumjs)
20
+
-[License](#license)
21
+
16
22
## Installation
17
23
18
24
To obtain the latest version, simply install the project using `npm`:
**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.
22
33
23
-
## Usage
34
+
## Getting Started
24
35
25
-
### Introduction
36
+
### Instantiation
26
37
27
38
There are several standalone functions to instantiate a `Block`:
28
39
@@ -82,7 +93,9 @@ try {
82
93
83
94
This library by default uses JavaScript implementations for the basic standard crypto primitives like hashing or signature verification (for included txs). See `@ethereumjs/common`[README](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common) for instructions on how to replace with e.g. a more performant WASM implementation by using a shared `common` instance.
84
95
85
-
### EIP-1559 Blocks
96
+
## EIP Integrations
97
+
98
+
### Blocks with an EIP-1559 Fee Market
86
99
87
100
By default (since `Hardfork.London`) blocks created with this library are [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) compatible.
88
101
@@ -141,7 +154,7 @@ try {
141
154
}
142
155
```
143
156
144
-
### EIP-4895 Beacon Chain Withdrawals Blocks
157
+
### Blocks with EIP-4895 Beacon Chain Withdrawals
145
158
146
159
Starting with the `v4.1.0` release there is support for [EIP-4895](https://eips.ethereum.org/EIPS/eip-4895) beacon chain withdrawals (`Hardfork.Shanghai` or higher). To create a block containing system-level withdrawals, the `withdrawals` data option together with a matching `withdrawalsRoot` can be used:
147
160
@@ -182,7 +195,7 @@ console.log(`Block with ${block.withdrawals!.length} withdrawal(s) created`)
182
195
183
196
Validation of the withdrawals trie can be manually triggered with the newly introduced async `Block.withdrawalsTrieIsValid()` method.
184
197
185
-
### EIP-4844 Shard Blob Transaction Blocks
198
+
### Blocks with EIP-4844 Shard Blob Transactions
186
199
187
200
This library supports the blob transaction type introduced with [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) (`Hardfork.Cancun` or higher), see the following example:
**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.
21
33
22
-
## Usage
34
+
## Getting Started
23
35
24
36
### Introduction
25
37
@@ -29,7 +41,7 @@ New blocks can be added to the blockchain. Validation ensures that the block for
29
41
30
42
The library also supports reorg scenarios e.g. by allowing to add a new block with `Blockchain.putBlock()` which follows a different canonical path to the head than given by the current canonical head block.
31
43
32
-
## Example
44
+
## Examples
33
45
34
46
The following is an example to instantiate a simple Blockchain object, put blocks into the blockchain and then iterate through the blocks added:
35
47
@@ -88,6 +100,10 @@ const main = async () => {
88
100
voidmain()
89
101
```
90
102
103
+
More examples can be found in the [examples](./examples/) folder.
104
+
105
+
## Setup
106
+
91
107
### Block Storage
92
108
93
109
For storing blocks different backends can be used. The database needs to conform to the [DB](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/util/src/db.ts) interface provided in the `@ethereumjs/util` package (since this is used in other places as well).
console.log(`The current chain ID is ${commonWithCustomChainId.chainId()}`)
72
87
```
73
88
74
-
###Custom Cryptography Primitives (WASM)
89
+
## Custom Cryptography Primitives (WASM)
75
90
76
91
All EthereumJS packages use cryptographic primitives from the audited `ethereum-cryptography` library by default. These primitives, including `keccak256`, `sha256`, and elliptic curve signature methods, are all written in native JavaScript and therefore have the potential downside of being less performant than alternative cryptography modules written in other languages and then compiled to WASM. If cryptography performance is a bottleneck in your usage of the EthereumJS libraries, you can provide your own primitives to the `Common` constructor and they will be used in place of the defaults. Depending on how your preferred primitives are implemented, you may need to write wrapper methods around them so they conform to the interface exposed by the [`common.customCrypto` property](./src/types.ts).
77
92
@@ -170,9 +185,7 @@ The `Common` class has a public property `events` which contains an `EventEmitte
console.log(`The London forkhash for this custom chain is ${common.forkHash('london')}`)
256
269
```
257
270
258
-
### Hardforks
271
+
##Hardfork Support and Usage
259
272
260
273
The `hardfork` can be set in constructor like this:
261
274
@@ -309,7 +322,7 @@ See one of the hardfork configurations in the `hardforks.ts` file
309
322
for an overview. For consistency, the chain start (`chainstart`) is considered an own
310
323
hardfork.
311
324
312
-
###EIPs
325
+
##Supported EIPs
313
326
314
327
EIPs are native citizens within the library and can be activated like this:
315
328
@@ -356,10 +369,6 @@ The following EIPs are currently supported:
356
369
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) - Set EOA account code (Prague)
357
370
-[EIP-7709](https://eips.ethereum.org/EIPS/eip-7709) - Read BLOCKHASH from storage and update cost (Verkle)
358
371
359
-
### Bootstrap Nodes
360
-
361
-
You can use `common.bootstrapNodes()` function to get nodes for a specific chain/network.
362
-
363
372
## EthereumJS
364
373
365
374
See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.
All components of this library have a public `events` property containing an `EventEmitter` object (using [EventEmitter3](https://github.com/primus/eventemitter3))
To obtain the latest version, simply require the project using `npm`:
@@ -106,7 +114,7 @@ Using ESM will give you additional advantages over CJS beyond browser usage like
106
114
107
115
See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.
0 commit comments