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";| Export | Kind | Purpose |
|---|---|---|
AtomicityEnforced | type | { atomicityEnforced: true } literal-type marker |
AtomicityNotEnforcedError | class | thrown by runtime guard on non-true value |
assertAtomicityEnforced(cfg, siteName) | fn | runtime check; call at top of every settle/dispute entry point |
composeAtomicSettleTx(args) | async fn | builds a 3-ix Transaction (gate strict + transferChecked + emit_feedback) |
deriveStandardAta(owner, mint, tokenProgram?) | fn | standard ATA helper |
AtomicSettleQuantuAccounts | type | the Quantu account bundle composeAtomicSettleTx threads through remaining_accounts |
ComposeAtomicSettleArgs | type | full arg shape, extends AtomicityEnforced |
ComposedAtomicSettle | type | return 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., 6 → CounterpartyTierBelowMin).
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.
Read next
mountTrustGate
Drop-in Express middleware. Adds the four x402 routes to any app — verify, receipt, settle, dispute — with the atomicity guard enforced at compile-time and runtime.
MCP server
Drop @agenttrust-sdk/mcp into Claude Desktop or Cursor and query the deployed AgentTrust programs in natural language. Twenty-one tools, four resources, three prompts.