Skip to main content
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

npm install @agether/sdk

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.

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:
FieldTypeRequiredDescription
chainIdChainIdNoTarget chain (default: Base 8453)
rpcUrlstringYesRPC endpoint URL
contractsobjectNoOverride contract addresses
scoringEndpointstringNoScoring 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

ChainIDStatusNotes
Base8453✅ ProductionAll contracts deployed, full functionality
Base Sepolia84532🔧 PartialIdentity only
Sepolia11155111🔧 PartialIdentity only
Ethereum1⏳ PlannedMorpho Blue ready, contracts pending
Hardhat31337🧪 TestingLocal 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