Starting a blockchain application
This guide explains how to set up a new project that uses the lisk-sdk
to bootstrap a preconfigured blockchain application.
Creating a blockchain application
Create a new file index.js
.
We want to use this file to store the code that will start the blockchain application by using the Lisk SDK.
In index.js
, import the Application
, genesisBlockDevnet
and configDevnet
from the the lisk-sdk
package.
const { Application, genesisBlockDevnet, configDevnet } = require('lisk-sdk');
Now use the objects to create a blockchain application:
const app = Application.defaultApplication(genesisBlockDevnet, configDevnet);
This will create a new blockchain application that uses genesisBlockDevnet
as the genesis block for the blockchain, and `configDevnet`to configure the application with common default options to run a node in a development network.
The Both objects can be customized before passing them to the Find out more in the guide about Configuring a blockchain application |
Use app.run()
to start the application:
app
.run()
.then(() => app.logger.info('App started...'))
.catch(error => {
console.error('Faced error in application', error);
process.exit(1);
});
After adding all of the above contents, save the file. Now it is possible to start a blockchain application with a default configuration, that will connect to a local devnet.
Starting the application
Start the application as shown below:
node index.js
To verify the application start, check the log messages in the terminal. If the start was successful, the application will enable forging for all genesis delegates and will start to add new blocks to the blockchain every 10 seconds.
After completing these steps, the default blockchain application of the Lisk SDK will now be running. It is now be possible to customize your application by registering new modules and plugins, and also adjusting the genesis block and config to suit your specific use case. |