Documentation

Add limits to your AI agent.

Curb wraps your agent's payments with simple rules — spending caps, an allowlist of who it can pay, and approvals for big payments — and writes every decision to Hedera so it's auditable. It plugs straight into the Hedera Agent Kit. Add it in a few lines of code, or set it up from your terminal with no code at all.

01

Install

Add Curb alongside the Hedera Agent Kit and SDK — they're its peer dependencies.

shell — run this in your terminal
npm i hedera-curb @hashgraph/hedera-agent-kit @hiero-ledger/sdk
02

Quickstart

One call — createCurb() — provisions everything and hands you the hooks you drop into the Agent Kit. After this, every payment your agent attempts is checked against your rules before it runs.

agent.ts
import { createCurb } from 'hedera-curb';

// one call sets up the audit topic, the policy registry, storage, and the policy
const curb = await createCurb({
  client,            // your Hedera operator client
  agentAccountId,    // the account the agent pays from
  perDay: 25,        // optional — daily spending cap (HBAR)
});

// drop the hooks into the Agent Kit — that's the whole integration
new HederaAIToolkit({ client, configuration: {
  context: { hooks: curb.hooks },
}});
What this does
  • Audit topiccreates an HCS topic where every decision (allowed / blocked / approved) is recorded immutably.
  • Policy registrycreates an HCS-2 topic that versions your spending rules on-chain, so any change is auditable.
  • Storagedefaults to an in-memory store (great for tests). Swap in Redis for production — see Storage below.
  • Starting policypublishes your caps to the registry so the on-chain policy is live from the first payment.
  • Returnsan object: { hooks, config, store, auditTopicId, policyTopicId }. Pass any of those back in to reuse existing topics.
03

Terminal setup (no code)

Don't want to write setup code? Run one command in your terminal. It creates the same two topics and prints their ids — paste them into your .env and you're governed.

shell — run this in your terminal
npx hedera-curb init --network testnet

# ✓ Audit topic:  0.0.x
# ✓ Policy topic: 0.0.y   (HCS-2, only you can change it)
04

Storage

Curb needs somewhere to track how much the agent has spent and which approvals are pending. For tests or a single server, the built-in in-memory store just works. For production — where you might run several servers — implement the small CurbStore interface against Redis or Postgres so the state is shared and survives restarts.

Spend is tracked as a rolling 24-hour window. A payment that's mid-flight places a short-lived hold so two payments can't both slip under the cap at the same time; once it settles, the hold becomes committed spend.

CurbStore — implement against Redis / Postgres
interface CurbStore {
  isAllowed(agent, account): Promise<boolean>;       // is this counterparty allowlisted?
  getDailySpend(agent): Promise<number>;             // committed (settled) spend in the window
  incrDailySpend(agent, amount): Promise<void>;
  tryReserveSpend(agent, key, amount, cap): Promise<boolean>; // place an atomic hold
  commitSpend(agent, key, amount): Promise<void>;             // hold → committed
  getApproval(requestId): Promise<Status | null>;
  setApproval(requestId, status, meta?): Promise<void>;
  consumeApproval(requestId): Promise<void>;          // approvals are single-use
}
05

The trust ladder

Curb enforces the same policy at three levels of trust. You pick how much to trust the server running the agent — start at L0 for speed, climb to L2 for guarantees that hold even if everything else is compromised.

L0Off-chain rules

This package. The hooks check your caps, allowlist, and approvals before every payment, and write each decision to Hedera. Fast and simple — but it trusts the server holding the agent’s key.

L1Verifiable & versioned

Every decision and every rule change lives on Hedera. The policy itself is versioned on an HCS-2 registry, and anyone can recompute the spend straight from the chain. Now the history and the rules can’t be quietly changed.

L2On-chain enforcement

CurbVault — a smart contract — enforces the caps and allowlist in Hedera consensus itself. Even if the agent’s key is stolen, it still can’t overspend or pay someone off the allowlist.

06

API reference

Every export, with full parameters, types, and examples. Click any entry for its page.

VERIFIABLE SPEND-CONTROL   ·   ENFORCED ON-CHAIN   ·   AGENTS CAN PAY — NOW THEY CAN’T OVERSPEND   ·   CURB × HEDERA   ·   VERIFIABLE SPEND-CONTROL   ·   ENFORCED ON-CHAIN   ·   AGENTS CAN PAY — NOW THEY CAN’T OVERSPEND   ·   CURB × HEDERA   ·