Configure a blockchain application

The Application instance which is exported by the Lisk SDK, is configured to run with the default config options that are defined in the Lisk Framework.

To change the configuration, pass a config object as a parameter when creating a new Application instance.

During the development of a blockchain application it is recommended to import and use the configDevnet object from the Lisk SDK. Together with genesisBlockDevnet, which defines the genesis block, it sets up a local development environment with 101 forging genesis delegates.

index.js of the Hello World app
const { Application, genesisBlockDevnet, configDevnet} = require('lisk-sdk'); (1)
const HelloTransaction = require('./hello_transaction');

configDevnet.label = 'hello-world-app'; (2)
//configDevnet.components.storage.user = 'lisk';
//configDevnet.components.storage.password = 'password';
//configDevnet.modules.http_api.access.whiteList = ["127.0.0.1","1.2.3.4"];
//configDevnet.modules.http_api.access.public = true;

const app = new Application(genesisBlockDevnet, configDevnet); (3)
app.registerTransaction(HelloTransaction);

app
    .run()
    .then(() => app.logger.info('App started...'))
    .catch(error => {
        console.error('Faced error in application', error);
        process.exit(0);
    });
1 Imports the configDevnet object.
2 Optionally it is possible to override certain options in configDevnet before creating the application instance.
3 Creates the application instance and passes the genesisBlockDevnet as genesis block and configDevnet as config.

Configuration options

List of all available config options

To obtain a complete overview of all configuration options for the Lisk SDK, please refer to the configuration reference.

Constants

Specific constants for the blockchain application are set inside configDevnet.genesisConfig. These constants allow the basic properties of the blockchain to be easily adjusted. For example, the time that elapses until a new block is forged, the network epoch time, and the block rewards.

In the alpha version of the Lisk SDK, at present not all of the available constants are configurable by the user yet. However, in future versions more constants will become configurable.

To view a full list of all constants and their predefined values, please see the file application_config_schema.js.

Default configuration options

The default configuration options are located in the Lisk SDK repository in GitHub:

  • framework/src/modules/<module-name>/defaults/config.js for each module.

  • framework/src/components/<component-name>/defaults/config.js for each component.

Go to the configuration reference, to obtain a summary of all available config options and their default values.

Each config.js file consists of 2 parts:

  1. JSON-schema specification for all available config options.

  2. Default values for the available config options for this specific module.

Please do not change the default values in these files directly as they will be overwritten when software updates are performed. Instead of changing the default values, define the custom configuration options inside your blockchain application.

The genesis block

The genesis block describes the very first block in the blockchain. It defines the initial state of the blockchain at the start of the network.

The genesis block is not forged by a delegate, such as all of the other blocks which come after the genesis block. Instead it is defined by the developer, when creating the Application instance of the blockchain application.

The devnet genesis block

The Lisk SDK exposes an object genesisBlockDevnet that holds all of the required important information to spin up a local development network.

Go to Github, to see the full file genesis_block_devnet.json

A genesis block generator to create genesis blocks will be included in the Lisk SDK eventually. For Lisk Alpha SDK, the exposed genesisBlockDevnet can be used as a template, and customized to your requirements.

The following template shown below describes all properties of a genesis block:

{
    "version": 0, (1)
    "totalAmount": "10000000000000000", (2)
    "totalFee": "0", (3)
    "reward": "0", (4)
    "payloadHash": "198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d", (5)
    "timestamp": 0, (6)
    "numberOfTransactions": 103, (7)
    "payloadLength": 19619, (8)
    "previousBlock": null, (9)
    "generatorPublicKey": "c96dec3595ff6041c3bd28b76b8cf75dce8225173d1bd00241624ee89b50f2a8", (10)
    "transactions": [], (11)
    "height": 1, (12)
    "blockSignature": "c81204bf67474827fd98584e7787084957f42ce8041e713843dd2bb352b73e81143f68bd74b06da8372c43f5e26406c4e7250bbd790396d85dea50d448d62606", (13)
    "id": "6524861224470851795" (14)
}
1 Block version.
2 The total amount of tokens that are transferred in this block.
3 The total amount of fees associated with the block.
4 Reward for forging the block.
5 Hashes of the combined transactional data blocks.
6 Epoch timestamp of when the block was created.
7 Number of transactions processed in the block.
8 Sum of data blocks of all transactions in this block in bytes.
9 Null, because the genesis block has no previous block by definition.
10 Public key of the delegate who forged the block.
11 List of transactions in the genesis block.
12 Current height of the blockchain, always equals 1 for the genesis block.
13 Signature of the block, signed by the delegate.
14 Block ID.