Minka Ledger SDK
A SDK for interacting with the Minka Ledger.
Getting started
Installation
Install this package by running:
npm install @minka/ledger-sdk
Basic usage
First, you need an instance of the LedgerSDK
class, you can pass an options object with the required
property baseUrl
pointing to the ledger you want to use.
const ledger = new LedgerSDK({
baseUrl: 'https://minka.inc..',
})
That ledger instance has different Clients and only one status
method that ret
Note: Most of the methods in the entire SDK are asynchronous
, meaning they return a promise you need to wait to be resolved by using async/await
(prefered) functions or .then()
at the end of the methods chain.
Clients
Each entity of the ledger has its own client, those clients are properties of the LedgerSDK
instance, for example the client for signers
will be returned in ledger.signers
if you used the example below to connect to the ledger.
Common client methods
All clients has common methods for listing (list
), fetching (read
) and initializing (init
) entities
list
The list
method allows you to fetch a list of the required entity, it has an optional object of type LedgerListParams
as param to pass pagination and filtering options to it. You can read more about it here
const output = await ledger.signers.list()
read
The read
method allows you to fetch a single record of the required entiy, it has a required string param that is the handle you want to fetch.
const output = await ledger.signers.read('handle')
init
the init
method allows you to initialize a new record builder
instance. record builders
provide a more convenient way to work with the records by implementing methods to hash, sign, test and send them to ledger. You can optionally pass initial record to init method, otherwise it will be initialized with an empty record.
const emptySignerRecord = await ledger.signers.init()
const response = await emptySignerRecord.send()
Keep in mind that methods are chainable, so you can easily create a record as follows;
await ledger.signers.init({ record: {} }).hash().sign([keyPair]).send()