Skip to main content

Get Started with cardanocli-js

cardanocli-js wraps the cardano-cli in JavaScript and makes it possible to interact with the cli-commands much faster and more efficient.

Prerequisites#

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

Install#

NPM#

npm install cardanocli-js

From source#

git clone https://github.com/Berry-Pool/cardanocli-js.gitcd cardanocli-jsnpm install

Get started#

const CardanocliJs = require("cardanocli-js");const shelleyGenesisPath = "/home/ada/mainnet-shelley-genesis.json";
const cardanocliJs = new CardanocliJs({ shelleyGenesisPath });
const createWallet = (account) => {  cardanocliJs.addressKeyGen(account);  cardanocliJs.stakeAddressKeyGen(account);  cardanocliJs.stakeAddressBuild(account);  cardanocliJs.addressBuild(account);  return cardanocliJs.wallet(account);};
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.vrf.vkey);

Visit cardanocli-js to see the complete API documentation.