'use strict';

const Chain = require('bcoin/lib/blockchain/chain');

const chain = new Chain({
  network: 'main'

(async () => {
  await chain.open();

The result is:

{ hash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
  version: '00000001',
  prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
  merkleRoot: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
  time: 1231006505,
  bits: 486604799,
  nonce: 2083236893,
  height: 0,
  chainwork: '0000000000000000000000000000000000000000000000000000000100010001' }

Where is the database for this located?

up vote 2 down vote accepted

Chain accepts parameter db, which can have multiple backends. By default it will be stored in memory. So this tip is coming from memory.

If you want to store it to File(For example full node stores it in PREFIX/chain) you need to pass db with backend(ldb for example) and specify either prefix or location.

prefix stands for general directory where chain and wallet will be stored. location specifies DB directly.

So if we wanted to store this db in /tmp/testnet-1/chain.ldb We could specify:

const chain = new Chain({ network: 'main', db: 'leveldb', location: '/tmp/testnet-1/chain', }); or

const chain = new Chain({ network: 'main', db: 'leveldb', prefix: '/tmp/testnet-1' });

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.