@coti-io/coti-cardano-cli

0.0.2-beta.0 • Public • Published

Coti cardano-cli

A package to run cardano-cli commands from nodejs, if you hold a blockfrost API-KEY you could add while creating a cardano-cli instance and get the data directly from there without running a cardano node.

npm package Downloads Issues

Install binaries

  1. Download the binaries from the cardano website (version 1.35.0) https://hydra.iohk.io/build/16934881
  2. Copy the cardano-cli to the bin dir, if it not exists create a bin dir in /bin
  3. run the following command on the cardano-cli file chmod +x cardano-cli

Install

npm install @coti-io/cardano-cli

Usage

import { CardanoCli } from '@coti-io/cardano-cli';
const options: ConstructorOptions = {
    network: 'testnet',
    testnetMagic: '1097911063',
    blockfrostApiKey: '<API_KEY>'
};
const cardanoCli = new CardanoCli(options);

cardanoCli.queryTip()
    .then( tip => console.log(tip))
    .catch(error => console.log(error));

cardanoCli.queryProtocolParameters()
  .then( protocolParameters => console.log(protocolParameters))
  .catch(error => console.log(error));

// Build raw transaction
const buildRawTransactionRequest = {
  "txsIn": [
    {
      "txHash": "<txHash>",
      "utxoIndex": 1 // txIndex
    }
  ],
  "txsOut": [
    {
      "address": "<address>",
      "amount": 100000000 // amount
    },

    {
      "address": "<address>",
      "amount": 798000000 // amount
    }
  ],
  "hereAfter": 63700063, // current slot number + x
  "fee": 1000000 // minmum transaction fee
}

cardanoCli.transactionBuildRaw(buildRawTransactionRequest).then(rawTx => {
  console.log(rawTx);
}).catch(error => {
  console.log(error)
})

const signTransactionRequest = {
  "rawTransaction": {
    "type": "TxBodyBabbage",
    "description": "",
    "cborHex": "<cborHex>"
  },
  "paymentKeys": [
    {
      "type": "PaymentExtendedSigningKeyShelley_ed25519_bip32",
      "description": "",
      "cborHex": "<cborHex>"
    }
  ]
}

cardanoCli.transactionSign(signTransactionRequest).then(signTx => {
  console.log(signTx);
}).catch(error => {
  console.log(error)
})

const submitTransactionRequest = {
  "signedTransaction": {
    "type": "Tx BabbageEra",
    "description": "",
    "cborHex": "<cborHex>"
  }
}


cardanoCli.submitTransaction(submitTransactionRequest).then(signTx => {
  console.log(signTx);
}).catch(error => {
  console.log(error)
})

Package Sidebar

Install

npm i @coti-io/coti-cardano-cli

Weekly Downloads

0

Version

0.0.2-beta.0

License

MIT

Unpacked Size

214 kB

Total Files

137

Last publish

Collaborators

  • roma-coti
  • etay_coti
  • ysaban
  • yyanivv
  • gmesika-coti
  • yoni_readonly
  • yuval-coti
  • vladi-coti
  • yonine
  • cotitech