0.1.0 • Published 4 years ago

lisk-genesis v0.1.0

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
4 years ago

Lisk Genesis Block Creator

Build Status Coverage Status Dependencies Status License: GPL v3

What is the Lisk Genesis Block Creator

The genesis block creator gives developers the possibility to customise their own genesis block for sidechain and blockchain app prototypes during the Lisk alpha SDK phase.

This is by no means meant to support the production phase yet.

Now with v2 genesis block support.

Installation

You can install Lisk Genesis by using npm

npm install lisk-genesis@0.1.0

Or using yarn

yarn add lisk-genesis@0.1.0

Usage

After installation you can use lisk-genesis. Below you the find possible function examples.

Construction

Starting with construction there are two options, use a generated passphrase for the genesis account or use a passphrase of your choosing.

const { GenesisBlock } = require('lisk-genesis');
const genesisBlock = new GenesisBlock('applicationName');
const { GenesisBlock } = require('lisk-genesis');
const genesisBlock = new GenesisBlock("applicationName", "medal differ embody nose prepare inherit popular allow pizza design youth more");

Add Transfer

To add funds to an account you can use the addTransfer() function

genesisBlock.addTransfer({
    recipientId: "18254294583320434366L",
    amount: "10000000000"
});

It's also possible to add multiple transfer transactions at once

genesisBlock.addTransfer([
    {
        recipientId: "18254294583320434366L",
        amount: "10000000000"
    },
    {
        recipientId: "7979485526436233387L",
        amount: "10000000000"
    }
]);

Add Delegate

To add delegates to your genesis block use the addDelegate() function

// Passphrase is optional if not given a random passphrase will be used and saved to genesis_delegates.json
genesisBlock.addDelegate({
    username: "genesis_0",
    passphrase: "trigger oblige mom orchard please knife slow mixed afraid until suspect setup"
});

It's also possible to add multiple delegates at once

genesisBlock.addDelegate([
    { username: "genesis_0" },
    { username: "genesis_1" },
    { username: "genesis_2" },
    { username: "genesis_3" },
    { username: "genesis_4" }
]);

Add Votes

To vote for delegates you can use the addVote() function. addVote uses two arguments passphrase and an array with usernames.

genesisBlock.addVote(
    "same swamp fade drink radio fancy matter error picnic dial tone cinnamon",
    ["genesis_1", "genesis_0"]
);

Save the Genesis Block

To save the genesis_block.json, genesis_account.json and genesis_delegates.json use the saveGenesisBlock() function.

genesisBlock.saveGenesisBlock('.', true);

Optional arguments are path default '.' and saveGenesisAccount default true.

Credits

Lisk Foundation for providing the basic building blocks for this module

License

Copyright © 2019 - 2020 Corbifex

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.


Copyright © 2019 - 2020 Corbifex

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.