RegistryClient

Static Methods
  • findConfigPda() — Derive the registry config PDA
  • findAgentPda(owner) — Derive the agent PDA for a given owner wallet
  • deriveAgentDid(owner) — Derive the did:sol identifier for an owner
  • findDeactivationRecordPda(owner, programId?) — Derive the deactivation record PDA
Instance Methods
  • registerAgent(params) — Register a new agent
  • updateAgent(params) — Update agent metadata (owner, agentPda, and optional: newCapabilities, newName, newServiceCategory, newVersion, newAgentCardUrl, newAgentCardHash)
  • deactivateAgent(params) — Permanently deactivate an agent (params: owner, agentPda)
  • closeAgent(params) — Close a deactivated agent account (params: owner, agentPda)
  • closeDeactivationRecord(params) — Close a deactivation record and reclaim rent
  • checkAgentEligibility(agentPda) — Check if an agent meets eligibility criteria (returns AgentProfile)
  • verifyAgent(agentPda) — Verify an agent is active
Fetchers
  • fetchConfig() — Fetch the registry configuration
  • fetchAgent(agentPda) — Fetch agent by PDA
  • fetchAgentByOwner(owner) — Fetch agent by owner wallet
  • resolveAgentByDid(did) — Resolve a did:sol to an agent
  • generateDidDocument(owner) — Generate a W3C DID Document for the agent
  • fetchDeactivationRecord(owner) — Fetch a deactivation record for an owner
TypeScript
import { RegistryClient } from '@vouch-protocol/sdk'; // Import the registry client

const registry = new RegistryClient(program, provider); // Pass Anchor program + provider

// Register a new agent
const tx = await registry.registerAgent({ // Creates on-chain agent PDA
  owner: wallet.publicKey, // Owner wallet public key
  name: 'my-agent', // Human-readable agent name
  serviceCategory: { commerce: {} }, // Agent's service category for discovery
  agentCardUrl: 'https://example.com/agent-card.json', // Public A2A Agent Card URL
  agentCardHash: cardHash, // SHA-256 of the Agent Card for integrity
});

// Look up an agent by owner
const agent = await registry.fetchAgentByOwner(ownerPubkey); // Reads the agent PDA from chain
const didDoc = await registry.generateDidDocument(ownerPubkey); // Build W3C DID Document from on-chain data

Example Returns

registerAgent()

Returns
// Transaction signature (string)
"5UfDuX...abc123"

fetchAgent() / fetchAgentByOwner()

Returns
// AgentIdentity
{
  owner: PublicKey("7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr"),
  tier: { standard: {} },
  capabilities: BN(15),
  name: "CommerceBot",
  serviceCategory: { commerce: {} },
  version: "1.0.0",
  agentCardUrl: "https://commercebot.example/.well-known/agent.json",
  agentCardHash: [171, 62, ...], // 32-byte SHA-256
  status: { active: {} },
  createdAt: BN(1710500000),
  updatedAt: BN(1710500000),
  bump: 255,
  reputationScore: 720,
  reputationUpdatedAt: BN(1710500000),
  reputationChangeToday: 0,
  reputationDayStart: BN(1710460800),
  tierEffectiveAt: BN(1710500000)
}

fetchConfig()

Returns
// VouchConfig
{
  admin: PublicKey("AdminPubkey..."),
  pendingAdmin: null,
  paused: false,
  treasury: PublicKey("TreasuryPubkey..."),
  usdcMint: PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
  tierThresholds: [BN(0), BN(100000000), BN(500000000), BN(1000000000)],
  cooldownPeriod: BN(86400), // 1 day in seconds (configurable)
  stakeToTxRatio: 5,
  bump: 254
}

resolveAgentByDid()

Returns
// Same AgentIdentity as fetchAgent()
{
  owner: PublicKey("7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr"),
  name: "CommerceBot",
  tier: { standard: {} },
  reputationScore: 720,
  ...
}

generateDidDocument()

Returns
{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/suites/ed25519-2020/v1"
  ],
  "id": "did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr",
  "controller": "did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr",
  "verificationMethod": [{
    "id": "did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr#key-1",
    "type": "Ed25519VerificationKey2020",
    "controller": "did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr",
    "publicKeyBase58": "7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr"
  }],
  "authentication": ["did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr#key-1"],
  "assertionMethod": ["did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr#key-1"],
  "service": [
    {
      "id": "did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr#agent-card",
      "type": "A2AAgentCard",
      "serviceEndpoint": "https://commercebot.example/.well-known/agent.json",
      "description": "A2A Agent Card for capability discovery"
    },
    {
      "id": "did:sol:7xKXtg2CW87d97TXJSDpHD4vMvnQ1985FchZRgCd9oPr#vouch-registry",
      "type": "VouchRegistry",
      "serviceEndpoint": "solana:VouchProgram...:BKq8rN4EwJQG3R9FnLhSGqJ2tNkh8cVRxvNApj7hbfQM",
      "description": "On-chain Vouch identity PDA"
    }
  ]
}