MonmouthMonmouth Docs

Wallet SDK Overview

Introduction

The Monmouth Wallet SDK is the primary interface for AI agents to interact with Monmouth. It provides:

  • Identity: Register and manage agent identities
  • Guardrails: Safety boundaries for autonomous operations
  • Policy Enforcement: Rules that govern agent behavior
  • Intent Resolution: High-level intents to transaction conversion
  • Reputation: Query and track agent trust scores

Installation

npm install @monmouth/wallet-sdk

Basic Usage

import { MonmouthWallet, MonmouthIdentity } from '@monmouth/wallet-sdk'
 
// Register an agent identity
const identity = await MonmouthIdentity.register({
  metadata: { name: 'MyAgent-001', capabilities: ['swap', 'transfer'] },
  guardians: [{ address: '0x...', role: 'owner' }],
})
 
// Initialize the wallet
const wallet = new MonmouthWallet({
  agentDid: identity.did,
  privateKey: process.env.AGENT_PRIVATE_KEY,
 
  // Configure guardrails
  guardrails: {
    maxTransactionValue: '1 ETH',
    dailySpendingLimit: '10 ETH',
  },
 
  // Configure policies
  policies: {
    requireApprovalAbove: '5 ETH',
  },
})
 
// Execute an intent
const result = await wallet.executeIntent({
  type: 'swap',
  fromToken: 'ETH',
  toToken: 'USDC',
  amount: '0.5 ETH',
})

Key Features

1. Identity Management

Register, delegate, and manage agent identities:

// Register identity
const identity = await MonmouthIdentity.register({ ... })
 
// Delegate to a hot wallet
await identity.delegate({
  wallet: '0x...',
  capabilities: ['swap'],
  expiry: '2025-12-31',
})
 
// Check reputation
const reputation = await identity.getReputation()

2. Guardrails

Guardrails are hard limits that cannot be exceeded:

guardrails: {
  maxTransactionValue: '1 ETH',      // Max single transaction
  dailySpendingLimit: '10 ETH',       // Daily cumulative limit
  allowedContracts: ['0x...'],        // Whitelist of contracts
  blockedAddresses: ['0x...'],        // Blacklist of addresses
}

3. Policies

Policies define conditional behavior:

policies: {
  requireApprovalAbove: '5 ETH',      // Human approval needed
  blockedOperations: ['selfdestruct'], // Forbidden operations
  maxGasPrice: '100 gwei',            // Gas price limits
}

4. Intent Resolution

Convert high-level intents to optimal transactions:

const intent = {
  type: 'swap',
  fromToken: 'ETH',
  toToken: 'USDC',
  amount: '1 ETH',
}
 
// SDK handles routing, gas estimation, execution
const result = await wallet.executeIntent(intent)

Configuration Reference

interface WalletConfig {
  // Identity
  agentDid?: string
 
  // Authentication
  privateKey?: string
  mnemonic?: string
 
  // Network
  rpcUrl?: string
  chainId?: number
 
  // Guardrails
  guardrails?: {
    maxTransactionValue?: string
    dailySpendingLimit?: string
    allowedContracts?: string[]
    blockedAddresses?: string[]
    allowedTokens?: string[]
  }
 
  // Policies
  policies?: {
    requireApprovalAbove?: string
    blockedOperations?: string[]
    maxGasPrice?: string
    allowedProtocols?: string[]
  }
 
  // Intent resolution
  intentResolution?: {
    minConfidence?: number
    preferredProtocols?: string[]
    maxHops?: number
  }
 
  // Guardian
  guardian?: {
    address: string
    approvalRequired?: boolean
  }
}

On this page