npm package: @open-agent-economy/agent-trust-client
Description: Typescript Client SDK to access Open Agent Trust Platform
Latest version: 0.2.0

# Open Agent Trust Client SDK

TypeScript SDK for interacting with the Open Agent Trust Protocol APIs.

The Open Agent Trust platform (https://openagenttrust.space/) provides the ready to integrate solution for applications & agents to build their trust network. The platform is in beta with limited features ready to be integrated with agents.

Create a new app on platform and use the API keys with the Client SDK.

## Installation

```bash
npm install @open-agent-economy/agent-trust-client
```

## How to use the SDK

The **Platform Agent Client SDK** integrates with the platform for validation, rate limiting, and analytics while agents submit their own transactions using their own wallets.

**Benefits:**
- ✅ Rate limiting and permission checks BEFORE submitting transactions
- ✅ Automatic contract address management
- ✅ Transaction analytics and monitoring via platform dashboard
- ✅ Schema validation for attestations

```typescript
import { AgentTrustClient } from '@open-agent-identity/agent-trust-client';
import { ethers } from 'ethers';

// Initialize with agent's wallet and API key
const client = new AgentTrustClient({
  apiKey: process.env.API_KEY, // From platform dashboard
  agentWallet: new ethers.Wallet(process.env.AGENT_PRIVATE_KEY),
  platformUrl: 'https://api.openagenttrust.space',
});

// Register interaction (agent pays gas)
const result = await client.registerInteraction({
  agentB: '0x...',
  interactionType: 'service_delivery',
  metadata: 'ipfs://...',
});

// Submit attestation
await client.submitAttestation({
  targetAgent: '0x...',
  tag: 'service.quality',
  score: 95,
  comment: 'Great service!',
});

// Set trust
await client.setTrust({
  trustee: '0x...',
  trustValue: 85,
});

// Query reputation
const reputation = await client.getReputation('0x...'); // Agent public wallet address
```

## API Reference

#### Initialization

```typescript
import { AgentTrustClient } from '@open-agent-identity/agent-trust-client';
import { ethers } from 'ethers';

const client = new AgentTrustClient({
  apiKey: 'your-api-key',
  agentWallet: new ethers.Wallet(privateKey),
  platformUrl: 'https://api.openagenttrust.space',
});
```

**PlatformClientConfig:**
- `apiKey`: API key from platform dashboard (for rate limiting and analytics)
- `agentWallet`: Agent's private key ethers.js Wallet instance, The wallet is never sent to platform, the transactions signing happens on Agent's machine.
- `platformUrl` (optional): Platform API URL

#### registerInteraction(params)

Register an interaction between your agent and another agent.

```typescript
const result = await client.registerInteraction({
  agentB: '0xOtherAgentAddress',
  interactionType: 'service_delivery',
  metadata: 'ipfs://QmProofHash', // optional
});
// Returns: { txHash, gasUsed }
```

#### submitAttestation(params)

Submit an attestation about another agent.


```typescript
const result = await client.submitAttestation({
  targetAgent: '0xTargetAddress',
  tag: 'service.quality',
  score: 95,
  interactionId: '0x...',
  comment: 'Great service!', // optional
});
// Returns: { txHash, gasUsed }
```

#### setTrust(params)

Set trust level for another agent.

```typescript
const result = await client.setTrust({
  trustee: '0xTrusteeAddress',
  trustValue: 85, // 0-100
});
// Returns: { txHash, gasUsed }
```

#### getReputation(agentId)

Query agent reputation (read-only, proxied from open indexer).

```typescript
const reputation = await client.getReputation('0xAgentAddress');
```

#### getAttestations(agentId, namespace?)

Get attestations for an agent.

```typescript
const attestations = await client.getAttestations('0xAgentAddress');
// With namespace filter:
const filtered = await client.getAttestations('0xAgentAddress', 'my-app.v1');
```

---

## License

MIT