cardanocli-pluts
Overview
cardanocli-pluts
is a library that wraps cardano-cli using Typescript allowing you to interact with the cli using the Types exposed by plu-ts
Prerequisites
cardano-node >= 1.29.0
node.js >= 12.19.0
plu-ts >= 0.2.0
Getting started
import { CardanoCliPluts } from "@harmoniclabs/cardanocli-pluts"
import { Value } from "@harmoniclabs/plu-ts"
const cli = new CardanoCliPluts({
network: "testnet 42"
});
async function main(){
const bobAddr = await cli.utils.readAddress( "./addresses/bob.addr" );
const { privateKey, publicKey } = await cli.address.keyGen();
const myAddr = await cli.address.build({
payment: { publicKey }
});
const myUtxos = await cli.query.utxo({
address: myAddr
});
const tx = await cli.transaction.build({
inputs: [{ utxo: myUtxos[0] }],
outpus: [
{
address: bobAddr,
value: Value.lovelaces(2_000_000)
}
],
changeAddress: myAddr
});
const txSigned = await cli.transaction.sign({
tx,
privateKey
});
console.log(
JSON.stringify(
txSigned.toJson(),
undefined,
2
)
);
cli.transaction.submit({ tx: txSigned })
}
main()