npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ethereumjs/e2store

v10.0.0

Published

E2Store support for EthereumJS

Readme

@ethereumjs/e2store v10

NPM Package GitHub Issues Actions Status Code Coverage Discord

| A collection of utility functions for Ethereum data storage formats. | | ------------------------------------------------------------------- |

@ethereumjs/e2store provides utilities for working with Ethereum data storage formats, including E2HS, Era1, and Era files. These formats are commonly used for storing historical blockchain data, beacon states, and block data in an efficient, provable, and standardized way.

Table of Contents

Installation

To obtain the latest version, simply require the project using npm:

npm install @ethereumjs/e2store

Usage

All helpers are re-exported from the root level and deep imports are not necessary. So an import can be done like this:

import { formatEntry } from "@ethereumjs/e2store"

E2HS

E2HS is a format for storing historical blockchain data along with proofs. It provides efficient access to block headers, bodies, and receipts, and can be used to bootstrap a Portal History Network DB.

Format E2HS

import { formatE2HS } from "@ethereumjs/e2store"

// Format data into E2HS format
// data is an array of block tuple data and an epoch index
const e2hs = await formatE2HS(data)

Read Tuples from E2HS

import { readTuplesFromE2HS, parseEH2SBlockTuple } from "@ethereumjs/e2store"

// Read all tuples from an E2HS file
const tuples = await readTuplesFromE2HS(filePath)
for await (const tuple of tuples) {
  const { headerWithProof, body, receipts } = parseEH2SBlockTuple(tuple)
  console.log(headerWithProof)
  console.log(body)
  console.log(receipts)
}

Read E2HS Tuple at Index

import { readE2HSTupleAtIndex, parseEH2SBlockTuple } from "@ethereumjs/e2store"

// Read a specific tuple by index
const tuple = await readE2HSTupleAtIndex(filePath, index)
const { headerWithProof, body, receipts } = parseEH2SBlockTuple(tuple)
console.log(headerWithProof)
console.log(body)
console.log(receipts)

Era1

Era1 files store historical data in epochs of 8192 blocks, making it efficient to access large ranges of historical data. Era1 block tuples contain a header, body, receipts, and total difficulty. The data can be verified by reconstructing the epoch accumulator, and validating again the accumulator root, also contained in the era1 file.

Export History as Era1

Export history from an EthereumJS client DB in epochs of 8192 blocks as Era1 files:

import { exportEpochAsEra1 } from "@ethereumjs/e2store"

const dataDir = PATH_TO_ETHEREUMJS_CLIENT_DB
const epoch = 0

// Generates ${dataDir}/era1/epoch-0.era1
await exportEpochAsEra1(epoch, dataDir)

Read Era1 file

readERA1 returns an async iterator of block tuples (header + body + receipts + totalDifficulty):

import {
  readBinaryFile,
  validateERA1,
  readERA1,
  parseBlockTuple,
  blockFromTuple,
  getHeaderRecords,
  EpochAccumulator,
} from "@ethereumjs/e2store"

const era1File = readBinaryFile(PATH_TO_ERA1_FILE)

// Validate era1 file
// Rebuilds epoch accumulator and validates the accumulator root
const isValid = validateERA1(era1File)
if (!isValid) {
  throw new Error('Invalid Era1 file')
}

// Read blocks from era1 file
const blocks = readERA1(era1File)

for await (const blockTuple of blocks) {
  const { header, body, receipts } = await parseBlockTuple(blockTuple)
  const block = blockFromTuple({ header, body })
  console.log(`Block number: ${block.header.number}`)
}

// Reconstruct epoch accumulator
const headerRecords = await getHeaderRecords(era1File)
const epochAccumulator = EpochAccumulator.encode(headerRecords)
const epochAccumulatorRoot = EpochAccumulator.merkleRoot(headerRecords)

Era

Era files are used to store beacon chain data, including beacon states and blocks.

Read Era file

import { readBeaconState, readBlocksFromEra } from "@ethereumjs/e2store"

const eraFile = readBinaryFile(PATH_TO_ERA_FILE)

// Extract BeaconState
const state = await readBeaconState(eraFile)
console.log(`Current slot: ${state.slot}`)

// Read Beacon Blocks from era file
let count = 0
for await (const block of readBlocksFromEra(eraFile)) {
  console.log(`Block slot: ${block.message.slot}`)
  count++
  if (count > 10) break
}

Common Use Cases

  1. Historical Data Access: Use E2HS and Era1 formats to efficiently access historical blockchain data
  2. Beacon Chain Analysis: Read and analyze beacon chain states and blocks using Era files
  3. Data Export: Export historical data in standardized formats for analysis or archival
  4. Portal History Network: Bootstrap a Portal History Network DB using E2HS
  5. Execution Client Sync: Sync an execution client without devp2p using Era1 or E2HS files

EthereumJS

See our organizational documentation 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 first.

License

MPL-2.0