Giter VIP home page Giter VIP logo

cardanocli-js's Introduction

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.
Donations (ADA): addr1q97x8rfnkw4pmdgnwjzavl8jvg77tuy6wn3wm90x9emwgj8nhh356yzp7k3qwmhe4fk0g5u6kx5ka4rz5qcq4j7mvh2sg67tj5

Prerequisites

  • cardano-node >= 1.29.0
  • 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({ shelleyGenesisPath });

const createWallet = (account) => {
  const payment = cardanocliJs.addressKeyGen(account);
  const stake = cardanocliJs.stakeAddressKeyGen(account);
  cardanocliJs.stakeAddressBuild(account);
  cardanocliJs.addressBuild(account, {
    paymentVkey: payment.vkey,
    stakeVkey: stake.vkey,
  });
  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);

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>
                ...

Tests

Install npm dev dependencies using npm install --also=dev.

Tests are using Jest framework and can be run by using npm -s run test command.

To configure the test suite, make a copy of .env.dist and rename it .env. Then change all parameters values to fit your environment.

Caution: The TEST_WORKSPACE_DIR will be deleted at the end of the test suite. NEVER USE AN EXISTING DIRECTORY !!! You may disable this behavior by commenting the cleanup function in test/index.test.js:

afterAll(() => {
    // cleanUpTestDirectory();
});

cardanocli-js's People

Contributors

alessandrokonrad avatar cardanative avatar catrielmuller avatar itsmestale avatar javiergradiche avatar karltaylor avatar pascallapointe avatar pyropy avatar sublayerio avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.