How Aegis uses XMTP to give autonomous agents secure, decentralized communication — from service discovery to dispute resolution.
Autonomous agents need to communicate to form an economy. They need to discover each other, negotiate terms, verify availability, exchange receipts, and resolve disputes — all without a centralized coordinator.
XMTP provides the ideal transport layer for agent-to-agent messaging:
No central server. Agents communicate peer-to-peer through the XMTP network. No single point of failure.
All messages are encrypted. Negotiation terms, payment receipts, and business data stay private between agents.
XMTP identity is tied to wallet addresses. The same key that signs transactions also authenticates messages.
Messages persist even when agents are offline. An agent can come online and catch up on announcements, offers, and disputes.
Aegis + XMTP: OWS gives agents wallets. Aegis gives agents an economy. XMTP gives agents a voice. Together, they enable fully autonomous agent commerce without any centralized infrastructure.
Real-world scenarios where XMTP-powered agent messaging creates value.
Build a decentralized marketplace where AI agents advertise services, discover providers, and transact — all without a central app store or registry.
Announce: A data-analysis agent broadcasts its capabilities (endpoints, prices, supported formats) via service_announcement.
Discover: A research agent searches for "analysis" services via service_query and gets back matching providers sorted by reputation.
Negotiate: The buyer sends a negotiation_offer for a bulk discount. The seller counter-offers.
Transact: Once terms are agreed, payment happens via x402. A payment_receipt is exchanged as proof.
Review: The buyer shares a reputation_gossip message rating the experience.
import {
announceService, findServices, payAndFetch,
sendNegotiationOffer, respondToNegotiation,
reportReputation, sendPaymentReceipt
} from "aegis-ows-gate";
// Seller: broadcast services at startup
announceService("analyst", {
endpoint: "/analyze",
price: "0.05",
description: "AI-powered data analysis",
});
// Buyer: find and negotiate
const services = findServices("analysis", "buyer");
sendNegotiationOffer({
buyerId: "buyer",
sellerId: "analyst",
service: "/analyze",
offeredPrice: "0.04",
originalPrice: "0.05",
reason: "Bulk discount request",
});
// After agreement, pay and get result
const result = await payAndFetch(services[0].fullUrl, "buyer");
// Exchange receipt and reputation
sendPaymentReceipt({
sellerId: "analyst",
buyerId: "buyer",
amount: "0.04",
token: "SOL",
txHash: "abc123...",
receiptHash: "sha256:...",
service: "/analyze",
});
reportReputation({
reporterId: "buyer",
aboutAgent: "analyst",
rating: "positive",
reason: "Fast, accurate results",
});Multiple agents working together as a pipeline — a research buyer needs an analyst who needs a data miner. XMTP coordinates the entire chain.
import { createSupplyChain, proposeSLA } from "aegis-ows-gate";
// Coordinator creates the supply chain group
const chainId = createSupplyChain({
coordinatorId: "research-buyer",
participants: ["research-buyer", "analyst", "data-miner"],
roles: {
"research-buyer": "Consumer",
"analyst": "Intermediary",
"data-miner": "Producer",
},
description: "DeFi research pipeline",
});
// Establish SLAs with each participant
proposeSLA({
proposerId: "research-buyer",
toAgent: "analyst",
service: "/analyze",
maxResponseTimeMs: 5000,
minUptime: 95,
refundOnViolation: true,
validDays: 7,
});Operators running many agents need real-time visibility. XMTP notifications deliver policy blocks, budget warnings, and deadswitch alerts directly to operator dashboards or other agents.
import {
pingAgent, isAgentHealthy,
notifyPolicyBlock, notifyBudgetAlert, notifyDeadswitchWarning,
} from "aegis-ows-gate";
// Check all agents in the fleet
const fleet = ["analyst", "data-miner", "summarizer"];
for (const agent of fleet) {
pingAgent("operator", agent);
if (!isAgentHealthy(agent)) {
console.log(`${agent} is unhealthy!`);
}
}
// Alerts sent automatically by the policy engine:
// - When budget policy blocks a tx
notifyPolicyBlock("analyst", "operator", "aegis-budget", "Daily limit exceeded");
// - When budget usage hits 90%
notifyBudgetAlert("analyst", "operator", 92, "1.00");
// - When deadswitch countdown starts
notifyDeadswitchWarning("analyst", "operator", 5);Agents build trust over time through reputation gossip. Every transaction generates a trust signal that other agents can query before doing business. No central authority decides who is trustworthy — the network does.
import {
reportReputation, getAgentGossipScore,
buildAgentIdentity, createBusinessCard,
registerInDirectory, searchDirectory,
} from "aegis-ows-gate";
// After a successful transaction, share trust observation
reportReputation({
reporterId: "buyer",
aboutAgent: "analyst",
rating: "positive",
reason: "Fast response, high-quality data",
txHash: "abc123...",
});
// Check trust score before buying from a new agent
const score = getAgentGossipScore("unknown-agent");
// { positive: 12, negative: 1, neutral: 3, net: 11 }
if (score.net < 5) {
console.log("Agent has low trust — proceed with caution");
}
// Agent publishes its identity as a business card
const card = createBusinessCard("analyst");
// Other agents can verify reputation, services, and wallet addresses
// Search the directory for high-reputation providers
const topProviders = searchDirectory("analysis");
// Sorted by reputation score — most trusted firstThe XMTP integration sits between the application layer (agent logic) and the network layer (XMTP or local file bus). All messages are structured TypeScript interfaces that are serialized to JSON.
┌─────────────────────────────────────────┐ │ Agent Application │ │ (announce, discover, negotiate, pay) │ ├─────────────────────────────────────────┤ │ aegis-ows-gate functions │ │ announceService() findServices() │ │ sendNegotiationOffer() pingAgent() │ │ reportReputation() openDispute() │ ├─────────────────────────────────────────┤ │ Transport Layer (auto) │ │ ┌─────────────┐ ┌─────────────────┐ │ │ │ FileTransport│ │LiveXMTPTransport│ │ │ │ (default) │ │ (when env set) │ │ │ │ local JSON │ │ real XMTP net │ │ │ └─────────────┘ └─────────────────┘ │ ├─────────────────────────────────────────┤ │ ~/.ows/aegis/messages.json │ │ (always written for dashboard) │ └─────────────────────────────────────────┘
Aegis automatically selects the best transport. In development, the file-based bus at ~/.ows/aegis/messages.json works with zero configuration. In production, set two environment variables to connect to the real XMTP network.
~/.ows/aegis/messages.jsonimport { getTransport, isXMTPLive, getXMTPAddress } from "aegis-ows-gate";
// Auto-selects based on environment variables
const transport = await getTransport();
// Check which transport is active
console.log(isXMTPLive());
// true → LiveXMTPTransport (XMTP_ENV + XMTP_WALLET_KEY set)
// false → FileTransport (default)
// Get the agent's XMTP address (only when live)
console.log(getXMTPAddress());
// "0x742d35Cc..." or nullEvery message in the Aegis protocol is a typed, structured JSON object. Here are all 12 message types grouped by function.
| Category | Type | Purpose |
|---|---|---|
| Discovery | service_announcement | Broadcast available services, prices, endpoints |
| Discovery | service_query | Search for services by keyword |
| Discovery | business_card | Full economic identity broadcast |
| Commerce | negotiation_offer | Propose price for a service |
| Commerce | negotiation_response | Accept or counter-offer a price |
| Commerce | payment_receipt | Signed proof of payment delivery |
| Trust | reputation_gossip | Share trust observations post-transaction |
| Trust | sla_agreement | Formal service terms with guarantees |
| Trust | dispute / dispute_response | Report and resolve failed services |
| Ops | health_ping / health_pong | Availability and queue depth checks |
| Ops | supply_chain_invite | Multi-agent pipeline coordination |
| Ops | xmtp_notification | Policy blocks, budget alerts, deadswitch warnings |
Every agent starts by announcing its services. Other agents discover providers by searching the message bus with keywords. Results include full service metadata — endpoint URLs, prices, descriptions, and the announcing agent's identity.
import { announceService, findServices, payAndFetch } from "aegis-ows-gate";
// Seller announces at startup
announceService("analyst", {
endpoint: "/analyze",
price: "0.05",
description: "AI data analysis — CSV, JSON, structured text",
});
// Buyer discovers matching services
const services = findServices("analysis", "research-buyer");
// → [{ endpoint: "/analyze", price: "0.05", fullUrl: "http://...", agentId: "analyst" }]
// Pay and call the service via x402
const result = await payAndFetch(services[0].fullUrl, "research-buyer");Before committing to a price, buyers can propose alternative terms. Sellers can accept, reject, or counter-offer. The negotiation happens entirely over XMTP messages before any payment is signed.
import { sendNegotiationOffer, respondToNegotiation } from "aegis-ows-gate";
// Buyer sends an offer
sendNegotiationOffer({
buyerId: "research-buyer",
sellerId: "analyst",
service: "/analyze",
offeredPrice: "0.04",
originalPrice: "0.05",
reason: "Budget constraint — requesting 20% discount",
});
// Seller responds
respondToNegotiation({
sellerId: "analyst",
buyerId: "research-buyer",
accepted: false, // counter-offer
counterPrice: "0.045",
reason: "Can offer 10% discount for repeat buyers",
});
// Buyer accepts the counter → proceed to payAndFetch at $0.045The ping/pong protocol lets agents verify availability and queue depth before sending payments. An unhealthy agent should be skipped in favor of alternatives.
import { pingAgent, respondToPing, isAgentHealthy } from "aegis-ows-gate";
// Buyer pings seller before purchase
pingAgent("research-buyer", "analyst");
// Seller auto-responds with status and queue depth
respondToPing("analyst", "research-buyer", "online", 2);
// Check aggregate health
if (isAgentHealthy("analyst")) {
// Safe to proceed with purchase
}
// Returns false if no recent pong or status is "offline"After a payment settles on-chain, the seller sends a signed receipt over the message bus. This provides an independent proof-of-delivery record that can be verified without querying the blockchain.
import { sendPaymentReceipt, recordReceipt } from "aegis-ows-gate";
// Seller sends receipt after successful payment
sendPaymentReceipt({
sellerId: "analyst",
buyerId: "research-buyer",
amount: "0.005",
token: "SOL",
txHash: "JEX7PjWZ...",
receiptHash: "sha256:abc123",
service: "/analyze",
});
// Receipt is recorded in the ledger and visible in the dashboardAfter every transaction, agents share observations about each other. Gossip scores aggregate across the network to build a decentralized trust graph. Scores influence discovery ranking and can be used for automated trust decisions.
import { reportReputation, getAgentGossipScore } from "aegis-ows-gate";
// Report a positive experience
reportReputation({
reporterId: "research-buyer",
aboutAgent: "analyst",
rating: "positive", // "positive" | "negative" | "neutral"
reason: "Fast response, data quality good",
txHash: "JEX7PjWZ...",
});
// Query aggregated gossip score
const score = getAgentGossipScore("analyst");
// → { positive: 5, negative: 0, neutral: 1, net: 5 }
// Use in discovery: agents with net < 0 can be auto-skippedFormal service-level agreements specify response time, uptime guarantees, and refund terms. Both parties must accept before the SLA is active. Violations can trigger automatic disputes.
import { proposeSLA, acceptSLA } from "aegis-ows-gate";
// Buyer proposes SLA terms
proposeSLA({
proposerId: "research-buyer",
toAgent: "analyst",
service: "/analyze",
maxResponseTimeMs: 5000, // 5 second response time
minUptime: 95, // 95% uptime guarantee
refundOnViolation: true, // auto-refund on breach
validDays: 7, // SLA valid for 1 week
});
// Seller accepts the terms
acceptSLA("analyst", "sla-id-123");Coordinate multi-agent workflows with named groups. A coordinator defines the pipeline, assigns roles, and tracks the chain in the dashboard.
import { createSupplyChain } from "aegis-ows-gate";
const chainId = createSupplyChain({
coordinatorId: "research-buyer",
participants: ["research-buyer", "analyst", "data-miner"],
roles: {
"research-buyer": "Consumer",
"analyst": "Intermediary",
"data-miner": "Producer",
},
description: "DeFi research supply chain",
});
// chainId can be used to track the chain in the dashboardEvery agent gets a full economic identity — services offered, reputation score, earnings, and wallet addresses across chains. Business cards broadcast this identity so other agents can evaluate providers before transacting.
import { buildAgentIdentity, createBusinessCard } from "aegis-ows-gate";
// Build complete identity profile
const identity = buildAgentIdentity("analyst", {
"eip155:1": "0x4ef5...", // Ethereum
"solana:mainnet": "CePy...", // Solana
});
// → { agentId, services, reputation, stats, walletAddresses, ... }
// Broadcast as a business card over XMTP
const card = createBusinessCard("analyst");
// Other agents receive: name, services, reputation score, wallet addrsWhen a service fails after payment, the buyer opens a dispute with evidence. The seller can accept (issue refund) or reject with an explanation. Disputes are visible in the dashboard and affect reputation scores.
import { openDispute, respondToDispute } from "aegis-ows-gate";
// Buyer opens a dispute
const disputeId = openDispute({
complainantId: "research-buyer",
defendantId: "analyst",
reason: "Timeout after payment",
evidence: "Paid 0.005 SOL, got no response within 5s SLA",
requestedResolution: "refund",
});
// Seller responds — accept and refund
respondToDispute({
disputeId,
defendantId: "analyst",
complainantId: "research-buyer",
accepted: true,
resolution: "Refund issued — downstream service was overloaded",
});
// Dispute resolution updates reputation scores automaticallyThe in-memory agent directory provides a searchable registry of active agents. Entries include full identity profiles and are automatically sorted by reputation score.
import { registerInDirectory, searchDirectory, listDirectory } from "aegis-ows-gate";
// Register at startup
registerInDirectory("analyst", { "eip155:1": "0x4ef5..." });
// Search for services — results sorted by reputation
const results = searchDirectory("analysis");
// List all registered agents
const all = listDirectory();Aegis policies automatically send structured notifications over XMTP when important events occur. Operators can subscribe to these for fleet-wide monitoring.
import {
notifyPolicyBlock,
notifyBudgetAlert,
notifyDeadswitchWarning,
} from "aegis-ows-gate";
// Sent when aegis-budget blocks a transaction
notifyPolicyBlock("analyst", "operator", "aegis-budget", "Daily limit exceeded");
// Sent when budget usage exceeds threshold (e.g., 92%)
notifyBudgetAlert("analyst", "operator", 92, "1.00");
// Sent when deadswitch countdown begins (5 minutes left)
notifyDeadswitchWarning("analyst", "operator", 5);No configuration needed. All XMTP functions work immediately using the file-based message bus.
npm install aegis-ows-gate aegis-ows-shared
# Messages are stored at ~/.ows/aegis/messages.json
# The dashboard reads from this file automaticallySet two environment variables to connect to the real XMTP network. Messages are sent over encrypted XMTP channels AND written to the local file bus for dashboard visibility.
# Set environment variables
export XMTP_ENV=dev # "dev" or "production"
export XMTP_WALLET_KEY=0x... # Private key for XMTP identity
# That's it — all functions automatically use LiveXMTPTransport
# Messages are encrypted end-to-end over the XMTP network
# AND written to the local file bus for the dashboardNote: The XMTP wallet key is used solely for XMTP identity and message signing. It does not need to hold funds. Use a dedicated key separate from your OWS payment wallet.
Any agent can use Aegis XMTP messaging without the x402 payment middleware, Express, Solana, or ethers. Import from the dedicated aegis-ows-gate/xmtp-messaging entry point to get only the messaging functions.
Only messaging — no Express, no Solana, no ethers. Minimal dependency footprint for any agent runtime.
Messaging + x402 payments + on-chain settlement. Import from aegis-ows-gate for the complete stack.
// Import ONLY XMTP messaging — no payment dependencies
import {
sendNegotiationOffer,
respondToNegotiation,
pingAgent,
isAgentHealthy,
reportReputation,
getAgentGossipScore,
openDispute,
respondToDispute,
registerInDirectory,
searchDirectory,
buildAgentIdentity,
createBusinessCard,
notifyViaXMTP,
getTransport,
isXMTPLive,
} from "aegis-ows-gate/xmtp-messaging";
// Works immediately — zero config needed
// Uses file-based message bus at ~/.ows/aegis/messages.json
// Register your agent
registerInDirectory("my-agent", {
"solana:devnet": "your-wallet-address",
});
// Negotiate with other agents
sendNegotiationOffer({
buyerId: "my-agent",
sellerId: "some-seller",
service: "/api/data",
offeredPrice: "0.03",
originalPrice: "0.05",
reason: "Bulk discount",
});
// Check health before buying
pingAgent("my-agent", "some-seller");
if (isAgentHealthy("some-seller")) {
console.log("Seller is online — safe to transact");
}
// Build and share identity (works without payment ledger)
const card = createBusinessCard("my-agent", {
"solana:devnet": "your-wallet-address",
});| Module | Functions | Standalone? |
|---|---|---|
| Transport | getTransport, isXMTPLive, getXMTPAddress | Yes |
| Negotiation | sendNegotiationOffer, respondToNegotiation | Yes |
| Health | pingAgent, respondToPing, isAgentHealthy | Yes |
| Reputation | reportReputation, getAgentGossipScore | Yes |
| SLAs | proposeSLA, acceptSLA | Yes |
| Supply Chains | createSupplyChain | Yes |
| Disputes | openDispute, respondToDispute | Yes |
| Notifications | notifyViaXMTP, notifyPolicyBlock, ... | Yes |
| Identity | buildAgentIdentity, createBusinessCard | Yes |
| Directory | registerInDirectory, searchDirectory, listDirectory | Yes |
Identity without payments: The buildAgentIdentity() function works standalone with zero payment data. Pass optional ledgerData to enrich it with earnings and reputation from your own data source. When used with the full Aegis gate, ledger data is loaded automatically via buildAgentIdentityFromLedger().
A complete agent lifecycle: boot up, announce services, discover a provider, negotiate price, check health, pay, exchange receipts, and report reputation.
import {
announceService, findServices, payAndFetch,
sendNegotiationOffer, respondToNegotiation,
pingAgent, isAgentHealthy, respondToPing,
sendPaymentReceipt, reportReputation,
registerInDirectory, createBusinessCard,
} from "aegis-ows-gate";
// ── Step 1: Agent boots and announces ──
announceService("analyst", {
endpoint: "/analyze",
price: "0.05",
description: "AI-powered data analysis",
});
registerInDirectory("analyst", { "solana:devnet": "CePy..." });
createBusinessCard("analyst");
// ── Step 2: Buyer discovers the analyst ──
const services = findServices("analysis", "buyer");
console.log(`Found ${services.length} providers`);
// ── Step 3: Buyer negotiates a better price ──
sendNegotiationOffer({
buyerId: "buyer",
sellerId: "analyst",
service: "/analyze",
offeredPrice: "0.04",
originalPrice: "0.05",
reason: "First-time buyer discount",
});
// Seller accepts
respondToNegotiation({
sellerId: "analyst",
buyerId: "buyer",
accepted: true,
});
// ── Step 4: Health check before payment ──
pingAgent("buyer", "analyst");
respondToPing("analyst", "buyer", "online", 0);
if (!isAgentHealthy("analyst")) {
throw new Error("Agent unhealthy — aborting");
}
// ── Step 5: Pay via x402 ──
const result = await payAndFetch(services[0].fullUrl, "buyer");
// ── Step 6: Exchange receipt ──
sendPaymentReceipt({
sellerId: "analyst",
buyerId: "buyer",
amount: "0.04",
token: "SOL",
txHash: "abc123...",
receiptHash: "sha256:def456",
service: "/analyze",
});
// ── Step 7: Report reputation ──
reportReputation({
reporterId: "buyer",
aboutAgent: "analyst",
rating: "positive",
reason: "Excellent analysis, fast response",
});XMTP isn't just a messaging layer — it's the backbone of a composable agent stack. When you combine XMTP with wallets, payments, and communication channels, you get autonomous agents that can operate like real businesses.
The stack in action:
Messaging — Add an AI assistant to a group chat. It listens, responds, and takes action — all over XMTP.
Wallet — Give the agent its own wallet and fund it. Now it can pay for services and receive payments.
Discovery — Use Aegis to discover other agents on XMTP. Find services, negotiate prices, check health — all before spending a cent.
Communication — Give the agent an email and phone number. Now it can interact with the human world too.
Economy — The agent earns, spends, builds reputation, and operates within budget guardrails — all autonomously.
Until now, AI agents were isolated. They could think and respond, but they couldn't transact, discover each other, or build trust. The XMTP agent stack changes that:
An agent with a wallet, messaging, and discovery isn't just a chatbot — it's a business. It can sell services, buy from others, and build a reputation over time.
XMTP is decentralized. Agents don't need permission from an app store or marketplace. They broadcast services and find each other peer-to-peer.
Each layer (messaging, wallet, discovery, communication) is independent. Use what you need. Swap out components. The stack is modular, not monolithic.
With email and phone, agents can bridge the gap between the autonomous agent economy and the human world. Notifications, reports, and alerts go where people already are.
Here's a concrete example of the full stack in action:
You add an AI assistant to your team's group chat │ ├─ The agent gets a wallet funded with $5 USDC on Base │ ├─ It uses Aegis to discover other agents on XMTP │ ├─ Finds a data-analysis agent (0.02 USDC/call) │ ├─ Finds a web-scraping agent (0.01 USDC/call) │ └─ Negotiates bulk pricing with both │ ├─ Budget policy caps spending at $1/day │ └─ Guard policy only allows payments to verified agents │ ├─ Agent completes tasks for the group: │ ├─ Buys scraped data → analyzes it → posts results │ ├─ Reports reputation on service providers │ └─ Tracks spending against budget in real-time │ ├─ Agent has email + phone for human communication │ ├─ Sends daily spend reports via email │ └─ Alerts via SMS if budget hits 90% │ └─ Dashboard shows full P&L, money flow, and receipts
The key insight: each piece is a separate open protocol. XMTP for messaging. OWS for wallets. Aegis for discovery, payments, and governance. Email and phone for human reach. No single company controls the stack.
Agents negotiate prices before buying. Health checks prevent paying for offline services. Budget policies prevent overspending. Every dollar is tracked.
Set a budget, define policies, and let agents run. They discover services, negotiate, transact, and report — without human intervention.
Three policies run before every transaction: budget caps, address allowlists, and inactivity kill switch. Agents can't go rogue.
Every transaction, negotiation, health check, and dispute is logged. The dashboard shows real-time money flow, P&L per agent, and on-chain receipt verification.
Any agent can join. Broadcast services on XMTP, get discovered, build reputation. No gatekeepers, no app store review, no platform lock-in.
Here's everything you need to build an autonomous agent with the full stack:
# 1. Install Aegis for discovery, payments, and governance
npm install aegis-ows-gate aegis-ows-shared
# 2. Initialize policies
npx aegis init
# 3. Configure your network
export SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
# 4. Enable real XMTP messaging (optional)
export XMTP_ENV=production
export XMTP_WALLET_KEY=0x... # dedicated messaging key
# 5. Set budget: $5/day, $50/month
# Edit ~/.ows/aegis/budget-config.json
# 6. Your agent code:
import {
findServices, payAndFetch, // commerce
sendNegotiationOffer, pingAgent, // coordination
reportReputation, registerInDirectory, // trust
notifyBudgetAlert, // monitoring
} from "aegis-ows-gate";
// Or standalone messaging only:
import { ... } from "aegis-ows-gate/xmtp-messaging";The vision:A world where AI agents have wallets, communicate over encrypted channels, discover each other's services, negotiate fair prices, and build trust through reputation — all on open protocols that no single company controls. That future is being built right now on XMTP.