Fabric Quickstart

Prerequisites

  1. (optional) Install NVM: https://nvm.sh
  2. Install Node 12.16
  3. Run node --version and verify the output matches 12.16
  4. See #1

Instructions

  1. Meet the prerequisites (above)
  2. Install Fabric Core: npm i --save @fabric/core

Note: for development releases, use npm i --save martindale/fabric#fabric instead.

Sample Program

Create the file scripts/quickstart.js using the following code:

const Bitcoin = require('@fabric/core/services/bitcoin');

async function main () {
  const bitcoin = new Bitcoin({
    verbosity: 3
  });

  await bitcoin.start();
}

main().catch((exception) => {
  console.error('[QUICKSTART]', 'Quick Start failed:', exception);
});

Finally, run the program:

> node scripts/quickstart.js
[AUDIT] Generating new HD key for wallet...
[AUDIT] Wallet account: {
  id: 'WLTTtuqaMtxMRiP33gLf1BN2js5HESWxHEhE',
  wid: 1,
  name: 'default',
  network: 'main',
  initialized: true,
  witness: false,
  watchOnly: false,
  type: 'pubkeyhash',
  m: 1,
  n: 1,
  accountIndex: 0,
  receiveDepth: 1,
  changeDepth: 1,
  nestedDepth: 0,
  lookahead: 10,
  receiveAddress: '1CxaBhXMiyNPGZ2K2gNprxY6BnCnKVoEgW',
  changeAddress: '1L3LYaPmHfUhLDtsjzw77bsqhzC5esx9qf',
  nestedAddress: null,
  accountKey: 'xpub6Cn1n6iWaPYRqoD4Ss9Sx4i2FLmdZ4ZSwb5NULg6DGCNXMVikaoRk3KFRihqRqLSPiNTDmVHgj7Ff1LMLidcveMf8kPHSX51CjBtZtCqiDU',
  keys: []
}