AgentTrust
AgentTrust
SDK

Exports reference

Every public export from @agenttrust-sdk/trustgate, grouped by concern.

The SDK ships three import surfaces. The /express and /client subpaths are tree-shake-friendly entry points; the root namespace re-exports everything else.

import { mountTrustGate }                   from "@agenttrust-sdk/trustgate/express";
import { gatePayment, settle, dispute }     from "@agenttrust-sdk/trustgate/client";
import { /* everything else */ }            from "@agenttrust-sdk/trustgate";

Source: trustgate/sdk/src/index.ts.

Atomicity guard

import {
  AtomicityEnforced,
  AtomicityNotEnforcedError,
  assertAtomicityEnforced,
  composeAtomicSettleTx,
  deriveStandardAta,
} from "@agenttrust-sdk/trustgate";
ExportKindPurpose
AtomicityEnforcedtype{ atomicityEnforced: true } literal-type marker
AtomicityNotEnforcedErrorclassthrown by runtime guard on non-true value
assertAtomicityEnforced(cfg, siteName)fnruntime check; call at top of every settle/dispute entry point
composeAtomicSettleTx(args)async fnbuilds a 3-ix Transaction (gate strict + transferChecked + emit_feedback)
deriveStandardAta(owner, mint, tokenProgram?)fnstandard ATA helper
AtomicSettleQuantuAccountstypethe Quantu account bundle composeAtomicSettleTx threads through remaining_accounts
ComposeAtomicSettleArgstypefull arg shape, extends AtomicityEnforced
ComposedAtomicSettletypereturn shape: { tx, instructions, accounts }

Source: trustgate/sdk/src/atomicity.ts.

SPL helpers

import {
  TOKEN_PROGRAM_ID,
  TOKEN_2022_PROGRAM_ID,
  ASSOCIATED_TOKEN_PROGRAM_ID,
  buildTransferCheckedIx,
  deriveAssociatedTokenAddress,
} from "@agenttrust-sdk/trustgate";

buildTransferCheckedIx accepts an optional tokenProgram to switch between legacy SPL and Token-2022. The atomic-tx invariant applies to both — Token-2022's TransferHook extension is the canonical corruption vector that motivates the invariant; legacy SPL's MissingRequiredSignature revert produces the same atomicity behaviour.

Source: trustgate/sdk/src/spl.ts.

On-chain validator factory

import {
  makeValidateOnChainTx,
  type OnChainTxValidation,
  type OnChainTxRejection,
  type ValidateOnChainTxFn,
  type MakeValidateOnChainTxOptions,
} from "@agenttrust-sdk/trustgate";

makeValidateOnChainTx({ connection, … }) returns a function the facilitator's /settle route plugs into the adapter's validatePaymentProof slot. Parses a confirmed SPL transfer transaction from RPC, cross-checks amount / mint / recipient / authority against the verify-time VerifyContext, and rejects mismatches with typed errors.

Source: trustgate/sdk/src/onchain-validator.ts.

Quantu helpers

import {
  DEFAULT_DEVNET_QUANTU_IDS,
  MAINNET_QUANTU_IDS,
  type QuantuProgramIds,
  type QuantuFeedbackAccounts,
  type QuantuFeedbackAccountsArgs,
  deriveAgentAccountPda,
  deriveAtomConfigPda,
  deriveAtomStatsPda,
  deriveAtomRegistryAuthorityPda,
  deriveQuantuFeedbackAccounts,
} from "@agenttrust-sdk/trustgate";

The Quantu* helpers derive Quantu PDAs without depending on Quantu's TypeScript package. Pinned to commit bfb09ad per Reference → Mainnet program IDs. deriveQuantuFeedbackAccounts returns the full account bundle the give_feedback CPI needs in remaining_accounts order.

Source: trustgate/sdk/src/quantu.ts.

emit_feedback factory

import {
  makeEmitFeedbackCpi,
  makePriorEmissionLookup,
  type EmitFeedbackCpiFn,
  type EmitFeedbackCpiInput,
  type EmitFeedbackResult,
  type MakeEmitFeedbackCpiOptions,
  type PriorEmissionLookupFn,
  type PriorEmissionResult,
  type MakePriorEmissionLookupOptions,
} from "@agenttrust-sdk/trustgate";

makeEmitFeedbackCpi({ connection, … }) returns the function adapters plug into their emitFeedback slot. makePriorEmissionLookup({ connection, … }) returns the priorEmissionLookup function — looks up FeedbackEmissionLog by payment_id_hash so retries return a stable receipt instead of double-emitting.

Source: trustgate/sdk/src/emit-feedback.ts.

ValidationRegistry

import {
  VALIDATION_REGISTRY_DEVNET_ID,
  deriveCapabilityNamespacePda,
  deriveAttestorProfilePda,
  deriveValidationRequestPda,
  deriveValidationAttestationPda,
  computeNamespaceHash,
  computeCapabilityHash,
  loadValidationRegistry,
  buildRegisterNamespaceIx,
  buildRegisterAttestorIx,
  buildRequestValidationIx,
  buildRespondToValidationIx,
  buildRevokeValidationIx,
  fetchValidationAttestation,
  fetchValidationRequest,
  fetchAttestorProfile,
  fetchCapabilityNamespace,
  type BuildRegisterNamespaceArgs,
  type BuildRegisterAttestorArgs,
  type BuildRequestValidationArgs,
  type BuildRespondToValidationArgs,
  type BuildRevokeValidationArgs,
} from "@agenttrust-sdk/trustgate";

Full instruction-builder set for the third leg of ERC-8004. computeCapabilityHash(name) returns SHA-256(name); computeNamespaceHash(name) is an alias kept for clarity. fetch* helpers return decoded views of each PDA.

Source: trustgate/sdk/src/validation-registry.ts.

PDA derivers + Anchor loaders

import {
  derivePolicyPda,
  deriveVelocityPda,
  deriveKillSwitchPda,
  deriveFeedbackLogPda,
  deriveTrustGateAuthorityPda,
  loadPolicyVault,
  loadTrustGate,
  makeProvider,
  simulateGatePayment,
  parseGateDecision,
} from "@agenttrust-sdk/trustgate";

load* helpers fetch the IDL from chain by default (anchor idl fetch <programId>). Pass an explicit idl argument to use a bundled snapshot — useful for latency-sensitive paths or freshly redeployed programs before anchor idl upgrade.

Source: trustgate/sdk/src/chain.ts.

x402 headers

import {
  buildHeadersForDecision,
  denyReasonName,
  X_PAYMENT_REQUIRED,
  X_PAYMENT_NETWORK,
  X_PAYMENT_REASON_CODE,
  X_PAYMENT_REASON_NAME,
  X_CAPABILITY_REQUIRED,
  X_AGENT_TRUST_DECISION,
} from "@agenttrust-sdk/trustgate";

buildHeadersForDecision(decision, network) returns the header map for Allow / Deny / RequireValidation. denyReasonName(code) maps 1..=15 to the canonical name (e.g., 6CounterpartyTierBelowMin).

Source: trustgate/sdk/src/x402.ts.

Types + constants

import {
  GateDecision,
  DenyReasonCode,
  ProgramIds,
  DEFAULT_DEVNET_PROGRAM_IDS,
} from "@agenttrust-sdk/trustgate";
type GateDecision =
  | { kind: "Allow" }
  | { kind: "Deny";              reasonCode: DenyReasonCode; reasonName: string }
  | { kind: "RequireValidation"; capabilityHash: Uint8Array };

interface ProgramIds {
  policyVault:        PublicKey;
  trustGate:          PublicKey;  // camelCase as of 0.2.0
  validationRegistry: PublicKey;  // new in 0.2.0
}

DEFAULT_DEVNET_PROGRAM_IDS carries the deployed-devnet IDs. Override via ProgramIds for mainnet redeploys. Source: trustgate/sdk/src/types.ts.

Express + client subpaths

These have their own dedicated entry points and don't re-export through the root namespace:

// Express middleware (peer dep: express ^4.21)
import { mountTrustGate } from "@agenttrust-sdk/trustgate/express";

// Client helpers
import { gatePayment, settle, dispute } from "@agenttrust-sdk/trustgate/client";

References: mountTrustGate, gatePayment.

On this page

⌘I