Skip to content

Latest commit

 

History

History
126 lines (88 loc) · 3.8 KB

File metadata and controls

126 lines (88 loc) · 3.8 KB

Initializing a Node

There are two ways to initialize a node: by command line and by code.

If you are using the CLI or code it is recommended that you configure your network using an Interbit configuration file. This file enables you to configure apps, peers, covenants, and chain joins all in one place.

Version Requirements

To develop Interbit applications, your development environment will need the following software:

Using the CLI

Once you have setup your configuration file to your liking you can use the start or build and deploy commands to start your node.

First, install the CLI in your project if you have not already. If you have followed the Getting Started guide and used the template this package and the following scripts are already configured with a corresponding interbit.config.js file.

Install the package

npm i --save interbit-cli

This adds interbit-cli to your npm project's package.json file.

Once you have added the dependency, you need to setup the start, or build and deploy scripts in your package.json scripts.

Using the package

Inside of package.json:

{
  "scripts": {
    "start": "interbit start --config interbit.config.js",
    "build": "interbit build --config interbit.config.js --manifest interbit.manifest.json",
    "deploy": "interbit deploy --manifest interbit.manifest.json"\
  }
}

Using Interbit with Code

You can also run a node using the interbit package, which the cli uses under the hood to make everything run. The interbit package contains more granular functionality and can be more customized.

Installing the package

You will need to install interbit in your dependencies list. If you have forked and are using the template it is already included as a dependency of interbit-cli

npm i --save interbit

Using the Package

The package comes with a set of granular functions for starting a node as well as a handy dandy deploy function that does all of the work of applying covenants, starting and loading chains, and creating an interbit instance and cli to interact with.

const {
  startInterbit,
  createChains: {
    createChainsFromConfig,
    createChainsFromManifest
  }
} = require('interbit')

const { cli, hypervisor } = startInterbit()

// You can use the cli to create chains, deploy covenants, and configure them from here

// ... or, you can create a set of chains using a config or manifest file

const config = require('interbit.config.js')
const { chainManifest, covenantHashes } = await createChainsFromConfig(cli, config)

const manifest = require('interbit.manifest.json')
await createChainsFromManifest(process.cwd(), cli, manifest)

Please check out the web-auth-endpoint package for an example of deploying a node in code. Please note that this package has used an interbit.config.js configuration file to build a manifest file prior to deploying the Interbit node.

Further Documentation: