This is emitted whenever the channel finishes the handshake process. You must wait for it to do any channel operations.
Example:
channel.on('ready', async () => {
// do something with the channel
const transactions = await channel.transactions.retrieve();
});
This is emitted whenever the keyring experiences an error initializing.
Example:
keyring.on("error", (error: Error) => {
// do something with the error
});
The coordinator object contains the methods for interacting with the coordinator.
The transactions object contains the methods for interacting with transactions.
Get the channel info.
Generated using TypeDoc
The Channel provides an interface that allows you to perform actions on karai channels.
The Channel class requires a keyring as a parameter for the constructor, so you'll have to create a keyring first.
You must listen for the
ready
event before doing anything with the channel.Example Usage:
import { Channel, KeyRing, Utils } from 'libkarai-js'; const keyring = new KeyRing(":memory:"); const channel = new Channel("zeus.karai.io:4200", keyring, false); channel.on("ready", async () => { console.log("Channel info: ", channel.info()); console.log("My public key is " + Utils.toHexString(keyring.getPub())); }); channel.on("error", async (error) => { // handle the error });