ERC-8004 Trustless Agents SDK - A TypeScript SDK for interacting with ERC-8004 compliant implementations
npm install @agentic-trust/8004-sdkbash
npm install @agentic-trust/8004-sdk
or
yarn add @agentic-trust/8004-sdk
or
pnpm add @agentic-trust/8004-sdk
`
Quick Start
`typescript
import { ERC8004Client, EthersAdapter } from '@agentic-trust/8004-sdk';
import { ethers } from 'ethers';
// Create an adapter for your preferred blockchain library
const provider = new ethers.JsonRpcProvider('https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY');
const adapter = new EthersAdapter(provider);
// Initialize the SDK
const client = new ERC8004Client({
adapter,
addresses: {
identityRegistry: '0x...',
reputationRegistry: '0x...',
// ... other contract addresses
}
});
// Use the client
const identity = await client.identity.getTokenURI(tokenId);
const reputation = await client.reputation.getReputationScore(agentAddress);
`
Core Components
$3
The main client that provides access to all ERC-8004 functionality:
`typescript
import { ERC8004Client } from '@agentic-trust/8004-sdk';
const client = new ERC8004Client({
adapter: yourAdapter,
addresses: {
identityRegistry: '0x...',
reputationRegistry: '0x...',
}
});
// Access different modules
const identity = client.identity;
const reputation = client.reputation;
const validation = client.validation;
`
$3
Handles identity-related operations:
`typescript
import { IdentityClient } from '@agentic-trust/8004-sdk';
const identityClient = new IdentityClient(adapter, identityRegistryAddress);
// Get token URI for an identity
const tokenURI = await identityClient.getTokenURI(tokenId);
// Get owner of an identity
const owner = await identityClient.getOwner(tokenId);
// Check if an identity exists
const exists = await identityClient.exists(tokenId);
`
$3
Manages reputation scoring and feedback:
`typescript
import { ReputationClient } from '@agentic-trust/8004-sdk';
const reputationClient = new ReputationClient(adapter, reputationRegistryAddress);
// Get reputation score
const score = await reputationClient.getReputationScore(agentAddress);
// Give feedback
await reputationClient.giveFeedback({
agent: agentAddress,
score: 5,
feedback: "Excellent service!",
metadata: { category: "quality" }
});
// Get feedback history
const feedback = await reputationClient.getFeedbackHistory(agentAddress);
`
$3
Provides validation utilities:
`typescript
import { ValidationClient } from '@agentic-trust/8004-sdk';
const validationClient = new ValidationClient(adapter);
// Validate agent metadata
const isValid = await validationClient.validateAgentMetadata(metadata);
// Validate reputation score
const isValidScore = validationClient.validateReputationScore(score);
`
Adapters
The SDK uses an adapter pattern to support different blockchain libraries:
$3
`typescript
import { EthersAdapter } from '@agentic-trust/8004-sdk';
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY');
const adapter = new EthersAdapter(provider);
`
$3
You can create your own adapter by implementing the BlockchainAdapter interface:
`typescript
import { BlockchainAdapter } from '@agentic-trust/8004-sdk';
class MyCustomAdapter implements BlockchainAdapter {
async call(contractAddress: string, abi: any, functionName: string, args: any[]): Promise {
// Your implementation
}
async send(contractAddress: string, abi: any, functionName: string, args: any[], options?: any): Promise {
// Your implementation
}
// ... implement other required methods
}
`
Types
The SDK exports comprehensive TypeScript types:
`typescript
import type {
AgentMetadata,
ReputationScore,
FeedbackData,
IdentityData,
BlockchainAdapter,
ContractAddresses
} from '@agentic-trust/8004-sdk';
`
Contract Addresses
You'll need to provide contract addresses for your target network:
`typescript
const addresses: ContractAddresses = {
identityRegistry: '0x...', // ERC-8004 Identity Registry
reputationRegistry: '0x...', // ERC-8004 Reputation Registry
// Add other contract addresses as needed
};
`
Supported Networks
- Ethereum Mainnet
- Ethereum Sepolia (testnet)
- Base Sepolia (testnet)
- Optimism Sepolia (testnet)
- Any EVM-compatible network with ERC-8004 contracts deployed
Development
$3
`bash
npm run build
`
$3
`bash
npm run dev
`
$3
`bash
npm run clean
`
Contributing
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)