@conduitprotocol/sdk
v0.3.0
Published
Conduit Protocol SDK + branded CLI: discover capabilities, pay via x402, settle USDC on Solana, fulfil hosted-mode provider jobs.
Downloads
561
Maintainers
Readme
@conduitprotocol/sdk
The four-call SDK + CLI for the Conduit Protocol — discover, pay, settle, profit.
Install
npm install @conduitprotocol/sdk @solana/web3.jsTry it without writing code
The SDK ships with a conduit CLI. No setup, no API keys — just point it
at any Conduit-compatible endpoint (defaults to the live mainnet API):
npx @conduitprotocol/sdk manifest
# → live catalog of every capability + best price across providers
npx @conduitprotocol/sdk health
# → ping the api-server, report latency
npx @conduitprotocol/sdk holdings <your-solana-pubkey>
# → show your SOL + USDC + token balancesOutput is colored, branded, and dogfoods the same SDK methods you'd call programmatically — so what you see in the terminal is exactly what your code gets back.
What this gives you
A typed client for every public Conduit endpoint, with the x402 lifecycle
baked in. Bring any wallet that can sendTransaction (Phantom, Backpack,
Solflare, Mobile Wallet Adapter, a server-side Keypair); the SDK handles
the rest.
Four endpoints, four lines of code
import { Conduit } from "@conduitprotocol/sdk";
import { PublicKey } from "@solana/web3.js";
const conduit = new Conduit({
apiBase: "https://conduit.network/api",
rpcUrl: "https://api.mainnet-beta.solana.com",
});
// 1. Discover every live capability + provider + price
const manifest = await conduit.manifest();
// 2. Pay for and invoke a resource in one call (x402 challenge → sign →
// finalize → POST with payment proof)
const result = await conduit.call({
resourceId: manifest.apiListings[0].id,
payload: { url: "https://example.com" },
signer,
mint: new PublicKey(manifest.mint!),
});
console.log(result.body); // provider's response
console.log(result.signature); // Solana tx sig on devnet/mainnetLower-level: the three-stage x402 lifecycle
If you want the explicit stages (e.g. to show a step-by-step UI), use the primitives directly:
// 1. Issue 402 challenge
const challenge = await conduit.requestChallenge({ apiId: 17 });
// 2. Build, sign, submit, wait for finalized, verify on backend
const paid = await conduit.payAndVerify(challenge, signer, mint);
// 3. (Optional) hit the per-resource gateway URL with the proof
await fetch(`${apiBase}/v1/resources/17/query`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Payment-Proof": `${paid.referenceId}:${paid.signature}`,
},
body: JSON.stringify({ ... }),
});What's different vs idle
- More generous economics — provider gets 92% (vs idle's 85%). Fee split is a single atomic transaction (provider + treasury + operator transfers in one signed tx).
- Relay layer — anyone can run a relay node and earn for verifying routes. Idle has no equivalent layer.
- Streaming Settlement — per-second / per-token continuous billing via on-chain Anchor program (Phase 2 rollout).
- On-chain staking + governance + slashing — protocol-level trust guarantees.
- SIWS wallet auth — every mutation cryptographically bound to a Solana signature, not an API key.
Wallet shape
The SDK accepts anything that satisfies ConduitSigner:
interface ConduitSigner {
publicKey: PublicKey;
sendTransaction(
transaction: Transaction,
connection: Connection,
options?: { ... },
): Promise<string>;
}Phantom / Backpack / Solflare's useWallet() return matches this directly.
For server-side use, wrap a Keypair in a small adapter.
License
(c) Conduit Protocol — see LICENSE.
