This package has been deprecated

Author message:

New package name format for new versions: @ethereumjs/blockchain. Please update.

ethereumjs-blockchain
TypeScript icon, indicating that this package has built-in type declarations

4.0.4 • Public • Published

SYNOPSIS

NPM Package Actions Status Coverage Status Gitter or #ethereumjs on freenode

A module to store and interact with blocks.

INSTALL

npm install ethereumjs-blockchain

API

./docs/

EXAMPLE

The following is an example to iterate through an existing Geth DB (needs level to be installed separately).

This module performs write operations. Making a backup of your data before trying it is recommended. Otherwise, you can end up with a compromised DB state.

const level = require('level')
const Blockchain = require('ethereumjs-blockchain').default
const utils = require('ethereumjs-util')
 
const gethDbPath = './chaindata' // Add your own path here. It will get modified, see remarks.
const db = level(gethDbPath)
 
new Blockchain({ db: db }).iterator(
  'i',
  (block, reorg, cb) => {
    const blockNumber = utils.bufferToInt(block.header.number)
    const blockHash = block.hash().toString('hex')
    console.log(`BLOCK ${blockNumber}${blockHash}`)
    cb()
  },
  err => console.log(err || 'Done.'),
)

WARNING: Since ethereumjs-blockchain is also doing write operations on the DB for safety reasons only run this on a copy of your database, otherwise this might lead to a compromised DB state.

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 do improvements on the libraries have a look at our contribution guidelines.

Readme

Keywords

Package Sidebar

Install

npm i ethereumjs-blockchain

Weekly Downloads

30,571

Version

4.0.4

License

MPL-2.0

Unpacked Size

117 kB

Total Files

18

Last publish

Collaborators

  • axic
  • holgerd77
  • sinamahmoodi
  • ralxz
  • kumavis
  • null_radix
  • jwasinger