AgentTrust
AgentTrust
SDK
SDK

@agenttrust-sdk/trustgate

TypeScript client helpers, Express middleware, and atomicity guard.

The SDK is the facilitator-facing TypeScript package.

pnpm add @agenttrust-sdk/trustgate

Imports

import { mountTrustGate } from "@agenttrust-sdk/trustgate/express";
import { gatePayment, settle, dispute } from "@agenttrust-sdk/trustgate/client";
import {
  AtomicityNotEnforcedError,
  DEFAULT_DEVNET_PROGRAM_IDS,
  derivePolicyPda,
} from "@agenttrust-sdk/trustgate";

gatePayment

gatePayment() is a read-only decision call.

type GateDecision =
  | { kind: "Allow" }
  | { kind: "Deny"; reasonCode: number; reasonName: string }
  | { kind: "RequireValidation"; capabilityHash: number[] };

The helper simulates the Anchor instruction and parses the return-data channel into the TypeScript union.

mountTrustGate

mountTrustGate(app, config) adds x402 routes to an Express service in fewer than 50 lines.

await mountTrustGate(app, {
  rpcUrl: "https://api.devnet.solana.com",
  facilitatorKeypair,
  defaultPolicyId: 1,
  network: "solana-devnet",
  atomicityEnforced: true,
});

Atomicity guard

settle, dispute, and middleware config require:

{ atomicityEnforced: true }

The marker is literal true, not boolean, and the runtime guard throws if a caller bypasses TypeScript with a cast.

v0.1 surface

APIStatus
gatePaymentimplemented
mountTrustGate /verifyimplemented
mountTrustGate /receiptimplemented
settleguarded surface, transaction builder follows
disputeguarded surface, transaction builder follows

Source: trustgate/sdk/src.

repo github.com/mohit-1710/agenttrustnpm @agenttrust-sdk/trustgateMIT

On this page

⌘I