jtmoderate876 / cardanocli-js

Wrapping the cardano-cli inside JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cardanocli-js

Overview

This is a library, which wraps the cardano-cli with JavaScript and makes it possible to interact with the cli-commands much faster and more efficient.

This library is brought to you by Berry Pool. You can support our work by delegating to our pool.

Prerequisites

  • cardano-node 1.24.2
  • node.js >= 12.19.0

Install

NPM

npm install cardanocli-js

From source

git clone https://github.com/Berry-Pool/cardanocli-js.git
cd cardanocli-js
npm install

Getting started

const CardanocliJs = require("cardanocli-js");
const shelleyGenesisPath = "/home/ada/mainnet-shelley-genesis.json";

const cardanocliJs = new CardanocliJs({ era: "allegra", shelleyGenesisPath });

const createWallet = (accout) => {
  cardanocliJs.addressKeyGen(accout);
  cardanocliJs.stakeAddressKeyGen(accout);
  cardanocliJs.stakeAddressBuild(accout);
  cardanocliJs.addressBuild(accout);
  return cardanocliJs.wallet(accout);
};

const createPool = (name) => {
  cardanocliJs.nodeKeyGenKES(name);
  cardanocliJs.nodeKeyGen(name);
  cardanocliJs.nodeIssueOpCert(name);
  cardanocliJs.nodeKeyGenVRF(name);
  return cardanocliJs.pool(name);
};

const wallet = createWallet("Ada");
const pool = createPool("Berry");

console.log(wallet.paymentAddr);
console.log(pool.file("vrf.vkey"));

Check /examples for more use cases.

API

Structure

All files will be stored and used in the directory you choose when instantiating CardanocliJs (dir). The directory is split in two subfolders tmp and priv. In the tmp folder are stored protocol paramters, raw transactions, signed transactions and witnesses with unique identifiers. The priv folder is again divided into two subolders holding on one site the pools pool and on the other side the wallets wallet (like CNTools structure).

Example structure:

dir
    tmp
        <tx_1.raw>
        ...
    priv
        pool
            Berry
                <Berry.node.vkey>
                <Berry.node.skey>
                <Berry.vrf.vkey>
                ...
        wallet
            Lovelace
                <Lovelace.payment.vkey>
                <Lovelace.stake.skey>
                ...

About

Wrapping the cardano-cli inside JavaScript


Languages

Language:JavaScript 100.0%