@0xragna/agent-rep
v1.0.0
Published
AgentRep SDK — On-chain reputation for AI agents
Downloads
176
Maintainers
Readme
@ragna/agent-rep
On-chain reputation protocol for AI agents. Soulbound identity + reputation scoring on Base.
Install
npm install @ragna/agent-repQuick Start
import { AgentRepClient } from '@ragna/agent-rep';
// Read-only (no wallet needed)
const client = new AgentRepClient();
// Get agent info
const agent = await client.getAgent(1);
console.log(agent.name); // "RagRadar"
console.log(agent.reputation); // 100n (raw, use formatReputation)
// Check reputation
const percent = await client.getReputationPercent(1);
console.log(percent); // "1.00"
const good = await client.isGoodStanding(1);
console.log(good); // false (needs >= 5.00%)
// Total agents
const total = await client.totalAgents();Write Operations (needs wallet)
import { AgentRepClient } from '@ragna/agent-rep';
import { baseSepolia } from 'viem/chains';
const client = new AgentRepClient({
chain: baseSepolia,
privateKey: '0x...', // your private key
});
// Register agent
const tx = await client.register('MyAgent', 'https://my-api.com');
// Stake ETH
const stakeTx = await client.stake(1, parseEther('0.01'));
// Score agent (requires scorer role)
const scoreTx = await client.score(1, 'api_uptime_30d');Contract
- Base Sepolia:
0xF11c856D021900f9c312e0e80913A7a0D6af40ED - Base Mainnet: coming soon
API
| Method | Description |
|--------|-------------|
| getAgent(id) | Get full agent info |
| getAgentByAddress(addr) | Get agent ID by owner |
| getReputationPercent(id) | Rep as "75.50" string |
| isGoodStanding(id) | Check if >= 5.00% |
| totalAgents() | Total registered |
| isScorer(addr) | Check scorer role |
| isSlasher(addr) | Check slasher role |
| getConstants() | Contract constants |
| register(name, endpoint) | Register new agent |
| score(id, reason) | Add reputation (scorer) |
| slash(id, reason) | Reduce reputation (slasher) |
| stake(id, amount) | Stake ETH |
| unstake(id, amount) | Unstake ETH |
| getAgents(start?, count?) | Get all agents |
Utilities
AgentRepClient.formatReputation(7550n); // "75.50%"
AgentRepClient.formatStake(1000000000000000000n); // "1.0000 ETH"License
MIT
