Package
@canister-software/consensus-cli is one npm package with two parts:
- the SDK,
ProxyClient,SocketClient, andcreatePaymentFetch(), which you import into your own JavaScript or TypeScript code; - the
consensuscommand, a CLI and full-screen TUI for tunnels, proxying, WebSockets, and leased IPs.
Install
Section titled “Install”As a project dependency, to use the SDK:
npm install @canister-software/consensus-cliGlobally, to use the consensus command anywhere:
npm install -g @canister-software/consensus-cliThe package is in beta; npm installs the current 0.2.0-beta release.
Requirements
Section titled “Requirements”| Use | Requires |
|---|---|
| SDK | Node.js 20.19 or newer, or Bun 1.3.0 or newer |
consensus command | Bun 1.3.0 or newer. The command runs on Bun even when installed with npm |
What it exports
Section titled “What it exports”import { ProxyClient, // route outbound HTTP through the network SocketClient, // open metered WebSocket sessions createPaymentFetch, // a fetch that answers x402 payment challenges resolveSigners, // load signers from CONSENSUS_* environment variables} from '@canister-software/consensus-cli'The package also exports connectToNode for the direct data path, batch and profile helpers, and their TypeScript types.
Next steps
Section titled “Next steps”- Setup: configure the CLI and payment credentials
- Client Setup: create
fetchWithPaymentfor the SDK - Usage: every
ProxyClientandSocketClientoption