@connext/channel-commitments
Usage
The CommitmentClient
is responsible for interacting with the backend to collect signatures for channel signers. It will be consumed by the claim UI to capture signatures from returning users to redeem commitments.
Interface
The class has the following interface:
class CommitmentClient {
public readonly SIGN_IN_PROMPT: string = "...";
public async post(signature: string, backend?: string): Promise<void> {}
}
Quickstart
- Install the package:
npm i @connext/channel-commitments
- Instantiate the client in your application:
import { CommitmentClient } from "@connext/channel-commitments";
const client = new CommitmentClient();
- Generate the signature:
const signature = await injectedProvider.signMessage(client.SIGN_IN_PROMPT);
- Post signature to backend:
try {
await client.post(signature);
} catch (e) {
console.warn("Failed to post to client");
}