Skip to main content

Clutch Hub SDK (JS) Overview

JavaScript/TypeScript SDK for client-side transaction signing and Clutch Hub API integration.

Features

  • Client-side signing — Private keys never leave the browser
  • Full ride lifecycle — Request, offer, accept, pay, cancel; plus Burn for CLT redemption
  • Chain-bound and verifiablechain_id in every signature; verifyUnsignedTransaction checks a hub-returned transaction before you sign it
  • GraphQL integration — Queries, mutations, and WebSocket subscriptions
  • Faucet helperrequestFaucet() for testnet CLT
  • TypeScript — Type-safe interfaces for all methods; amounts are bigint
v3: breaking changes

Amounts are now bigint (not number), the constructor takes an optional chainId, and the signed wire format gained a field. See v3 breaking changes before upgrading from v2.

Install

npm install clutch-hub-sdk-js

Quick example

import { ClutchHubSdk } from 'clutch-hub-sdk-js';

const CHAIN_ID = 2077; // from your app config — never from the hub

const sdk = new ClutchHubSdk('http://localhost:3000', publicKey, undefined, CHAIN_ID);

await sdk.requestFaucet(publicKey);

const tx = await sdk.createUnsignedRideRequest({
pickup: { latitude: 35.7, longitude: 51.4 },
dropoff: { latitude: 35.8, longitude: 51.5 },
fare: 5_000_000n, // $5.00 at 1 USD = 1,000,000 CLT
});

const signed = await sdk.signTransaction(tx, privateKey, { type: 'RideRequest', fare: 5_000_000n });
await sdk.submitTransaction(signed.rawTransaction);

Documentation

Source

clutch-hub-sdk-js on GitHub · npm