Advanced

Monitoring your channel

Accessing Channel State

Information about channel state can be accessed with getChannel(). This includes current node and client balances, availability of channel, and more.

Usage Example

Information about channel state retrieved with getChannel() can be used (for example) to stop execution if certain conditions are not met:

    var channelAvailable = await channel.getChannel()).available
    if (!channelAvailable) {
      console.warn(`Channel not available yet.`);
      return;
    }

Event Monitoring

The Connext client is an event emitter. You can trigger actions such as transfer confirmations in your application by listening for events using connext.on(). connext.on() accepts a string representing the event you’d like to listen for, as well as a callback. Available events are:

CHALLENGE_INITIATED
CHALLENGE_RESPONDED
CHALLENGE_RESOLVED
COUNTER_DEPOSIT_CONFIRMED
CREATE_CHANNEL
DEPOSIT_CONFIRMED
DEPOSIT_FAILED
DEPOSIT_STARTED
INSTALL
INSTALL_VIRTUAL
PROPOSE_INSTALL
PROPOSE_INSTALL_VIRTUAL
PROPOSE_STATE
PROTOCOL_MESSAGE_EVENT
REJECT_INSTALL
REJECT_INSTALL_VIRTUAL
REJECT_STATE
UNINSTALL
UNINSTALL_VIRTUAL
UPDATE_STATE
WITHDRAW_EVENT
WITHDRAWAL_CONFIRMED
WITHDRAWAL_FAILED
WITHDRAWAL_STARTED

Example:

connext.on("DEPOSIT_STARTED", () => { 
  console.log("Your deposit has begun")
  this.showDepositStarted()
});

Availability

The wallet must acknowledge every state update by cosigning that state. This means in order to update your channel, the user must be online. We’ve built several different transaction types to help accomodate user availability constraints.