The @agether/sdk package provides everything you need to integrate Agether into your AI agent or application. It ships five client classes, a CLI, utility functions, and all contract ABIs.
Installation
Architecture
The SDK is organized around five focused clients, each handling a different part of the protocol:
@agether/sdk
├── AgetherClient ← Account management, balances, funding
├── MorphoClient ← Morpho Blue lending & supplying via Safe + ERC-4337 (primary client)
├── ScoringClient ← Credit scoring API
├── X402Client ← HTTP 402 payment protocol
└── AgentIdentityClient ← ERC-8004 identity + reputation
The SDK uses Safe + Safe7579 + ERC-4337 under the hood. All state-changing operations are submitted as UserOps through the EntryPoint, validated by the Agether8004ValidationModule, and executed via the Safe7579 adapter.
AgetherClient Account creation, balances, funding, and withdrawals. The foundation for agent operations.
MorphoClient The primary client — deposit collateral, borrow USDC, supply USDC to earn yield, repay, withdraw. Handles market discovery and ERC-4337 UserOps.
ScoringClient Query credit scores, read onchain attestations, and trigger fresh score computations.
X402Client Make paid HTTP requests with automatic USDC micropayments via the x402 protocol.
AgentIdentityClient Register and manage ERC-8004 agent identities, metadata, and reputation.
Quick Example
import { MorphoClient } from '@agether/sdk' ;
// Initialize the primary lending client
const morpho = new MorphoClient ({
privateKey: process . env . AGENT_PRIVATE_KEY ! ,
rpcUrl: 'https://base-rpc.publicnode.com' ,
});
// Register agent identity
const { agentId , agentAccount } = await morpho . register ();
console . log ( 'Registered agent:' , agentId );
console . log ( 'Smart wallet:' , agentAccount );
// Check available markets
const markets = await morpho . getMarkets ();
console . log ( 'Markets:' , markets . length );
// Deposit collateral and borrow USDC
await morpho . depositAndBorrow ( 'WETH' , '0.1' , '100' );
console . log ( 'Deposited 0.1 WETH, borrowed $100 USDC' );
// Supply USDC to earn yield
await morpho . supplyAsset ( '500' , 'WETH' );
console . log ( 'Supplied $500 USDC to WETH market to earn yield' );
Configuration
All clients accept a configuration object with these common fields:
Field Type Required Description chainIdChainIdNo Target chain (default: Base 8453) rpcUrlstringYes RPC endpoint URL contractsobjectNo Override contract addresses scoringEndpointstringNo Scoring API URL
Contract addresses for Base mainnet are baked into the SDK — you don’t need to specify them unless you’re on a different network or using custom deployments.
Supported Chains
Chain ID Status Notes Base 8453 ✅ Production All contracts deployed, full functionality Base Sepolia 84532 🔧 Partial Identity only Sepolia 11155111 🔧 Partial Identity only Ethereum 1 ⏳ Planned Morpho Blue ready, contracts pending Hardhat 31337 🧪 Testing Local fork for development
Utilities
The SDK includes formatting and configuration helpers:
import {
parseUnits ,
formatUnits ,
formatUSD ,
formatAPR ,
formatAddress ,
getDefaultConfig ,
getUSDCAddress ,
} from '@agether/sdk' ;
// Parse $100 USDC (6 decimals)
const amount = parseUnits ( '100' , 6 ); // 100000000n
// Format for display
formatUSD ( amount ); // "$100.00"
formatAPR ( 1200 ); // "12.00%"
formatAddress ( '0x871e...0c8b' ); // "0x871e...0c8b"
// Get default config for a chain
const config = getDefaultConfig ( ChainId . Base );
Error Handling
The SDK provides typed errors for common failure cases:
import { AgetherError } from '@agether/sdk' ;
try {
await morpho . depositAndBorrow ( 'WETH' , '0.1' , '100' );
} catch ( error ) {
if ( error instanceof AgetherError ) {
console . log ( 'Error:' , error . message );
console . log ( 'Details:' , error . details );
}
}
Project Structure
sdk/
├── src/
│ ├── clients/
│ │ ├── AgetherClient.ts # Account management client
│ │ ├── MorphoClient.ts # Morpho Blue lending client
│ │ ├── ScoringClient.ts # Scoring service client
│ │ ├── X402Client.ts # x402 payment client
│ │ └── AgentIdentityClient.ts # ERC-8004 client
│ ├── types/
│ │ └── index.ts # Type definitions
│ ├── utils/
│ │ ├── format.ts # Formatting utilities
│ │ ├── config.ts # Config helpers + contract addresses
│ │ └── abis.ts # Contract ABIs
│ └── index.ts # Main exports
├── package.json
└── README.md
Next Steps