Opacus Documentation

Opacus is the operating system for AI agents — a decentralized execution layer that bridges AI intelligence with blockchain actions through secure, auditable, and policy-enforced infrastructure.

🚀 What is Opacus?

Opacus provides the critical Layer 4 infrastructure in the emerging AI agent economy. We enable autonomous agents to make decisions, validate actions, and execute transactions across multiple blockchains with built-in security and auditability.

Core Capabilities

🧠

AI Decision Making

Multi-LLM support including decentralized GLM-5 inference via 0G Compute

🛡️

Security Validation

Policy engine enforces permissions, budgets, and transaction constraints

🤖

Agent Execution

Autonomous agents discover services, negotiate, and execute across chains

⛓️

On-chain Settlement

Final transaction execution with transparency and immutability

The Problem AI Agents Face

Large Language Models have achieved remarkable reasoning capabilities, but they face a fundamental limitation: they cannot act in the real world.

Current AI Limitations

No Execution

Cannot send payments, execute swaps, or interact with smart contracts

⚠️

No Security

No validation layer between AI decisions and real-world consequences

🔒

Not Auditable

AI actions cannot be traced, verified, or held accountable

💔

Isolated Agents

Agents cannot discover each other or form collaborative networks

⚠️ The Gap

AI can think (reasoning, planning, communication)
But AI cannot do (payments, transactions, execution)

Opacus fills this gap.

Our Solution: Execution Kernel + Agent Runtime

Opacus provides the missing infrastructure layer between AI intelligence and blockchain execution.

Execution Flow

1. AI Decision
LLM analyzes task → generates execution plan → creates intent
2. Kernel Validation (Opacus)
Policy engine checks permissions → validates constraints → enforces limits
3. Agent Execution
Discover services → negotiate terms → prepare transaction
4. On-chain Settlement
Execute transaction → verify finality → emit events

Key Components

Execution Kernel

The core runtime that orchestrates AI inference, policy validation, and transaction execution. Ensures every action is authorized, auditable, and reversible if needed.

Policy Engine

Deterministic rule validator that gates on-chain execution. Checks:

Agent Runtime

Execution environment for autonomous agents. Features:

Quick Start

Installation

git clone https://github.com/opacus-labs/opacus
cd opacus

# Install Agent Kernel
cd agent-kernel
npm install
npm run build

Configuration

Create .env file with your settings:

# LLM Provider (use 0G for decentralized AI)
LLM_PROVIDER=0g
OG_RPC=https://rpc.0g.ai
OG_MODEL=glm-5

# Chain Configuration
BASE_MAINNET_RPC_URL=https://mainnet.base.org
ENABLE_AGENT_FINANCIAL_EXECUTION=true

# Executor Wallet (for on-chain transactions)
OPACUS_EXECUTORS_JSON='[{"id":"default","name":"executor-1","privateKey":"0x..."}]'

# Security Token
AGENT_EXECUTION_TOKEN=your-secret-token

Start the Kernel

PORT=3001 node dist/api-server.js

Access Dashboard

# Serve the frontend
npx serve website -l 8080

# Open in browser
open http://localhost:8080/agentboard.html

✅ You're Ready!

Agent Kernel is now running. Connect your dashboard to start deploying autonomous agents.

Execution Kernel Architecture

The Execution Kernel is the heart of Opacus. It's a Node.js/TypeScript runtime that:

Kernel Workflow

User Intent
    ↓
Intent Parser (LLM)
    ↓
Policy Validation
    ↓
[Approved] → Agent Execution → Transaction
    ↓
[Denied] → Return error + explanation

Security Model

Agent Runtime Environment

The Agent Runtime provides the execution environment where autonomous agents live and operate.

Agent Capabilities

Capability Description
Memory CRDT-based persistent storage for agent state and knowledge
Discovery Find other agents by capability, reputation, or location (H3 geospatial)
Communication QUIC/WebTransport messaging with CBOR framing
Payments USDC micropayments via OpacusPay for agent services
Execution Call smart contracts, bridge assets, submit transactions

DID Identity System

Every agent has a decentralized identifier (DID):

did:opacus:h3:<h3Index>:<address>

Features:

Policy Engine

The Policy Engine is a deterministic validation layer that prevents unauthorized or unsafe agent actions.

Policy Types

1. Budget Policies

{
  "dailyLimit": "100 USDC",
  "perTransactionMax": "10 USDC",
  "weeklyLimit": "500 USDC"
}

2. Token Allowlists

{
  "allowedTokens": ["USDC", "WETH", "OG"],
  "blockedTokens": ["SCAM_TOKEN"]
}

3. Chain Permissions

{
  "allowedChains": ["base", "0g", "ethereum"],
  "blockedChains": ["untrusted-testnet"]
}

4. Action Restrictions

{
  "allowedActions": ["swap", "bridge", "query"],
  "blockedActions": ["mint_governance_tokens"]
}

Validation Flow

1. Parse Intent (what does agent want?)
2. Check Budget (is there enough balance?)
3. Check Token (is asset approved?)
4. Check Chain (is network allowed?)
5. Check Action (is operation permitted?)
6. Check Rate Limit (cooldown expired?)
   ↓
[All Pass] → Approve Execution
[Any Fail] → Deny with reason

💡 Why Deterministic?

Policy validation uses strict rules, not AI. This ensures:

  • Predictable behavior (no LLM hallucinations)
  • Auditable decisions (clear pass/fail logic)
  • Legal compliance (provable enforcement)

Security Model

Threat Model

Threat Mitigation
Malicious prompt injection Policy engine validates output, not input
Unauthorized transactions Execution tokens + server-side validation
Fund drainage Daily limits + per-transaction caps
Replay attacks Nonce-based anti-replay protection
Private key exposure Executor wallet isolation + HSM support

Custodial Model (Phase 1)

Current version uses custodial executor wallets:

🔐 Future: Non-Custodial

Phase 2: Smart contract vault (reduce custody surface)
Phase 3: Decentralized execution layer (distributed executors)

Technology Stack

0G Compute & GLM-5

0G Compute is a decentralized AI inference network that powers agent reasoning.

Decentralized

No single point of failure or vendor lock-in

Censorship-Resistant

Cannot be shut down by any authority

Cost-Effective

Network pricing vs centralized API fees

GLM-5 Model

Large context, blockchain-optimized reasoning

Configuration

LLM_PROVIDER=0g
OG_RPC=https://rpc.0g.ai
OG_MODEL=glm-5
OG_TIMEOUT_MS=30000

Fallback Chain

Opacus supports multi-provider fallback:

1. 0G GLM-5 (decentralized) ← Primary
2. OpenAI GPT-4          ← Fallback 1
3. Anthropic Claude       ← Fallback 2
4. Ollama (local)         ← Fallback 3
5. Mock LLM               ← Final safety

If 0G Compute is unavailable, the kernel automatically fails over to centralized providers, ensuring 100% uptime for agent operations.

✅ Production Ready

0G GLM-5 integration is live. See integration guide for details.

0G Data Availability

0G DA provides high-throughput storage for agent memory and state persistence.

Why DA Matters for Agents

CRDT Memory System

Opacus uses Conflict-free Replicated Data Types for agent memory:

PUT  /memory/{key}          # Store data
GET  /memory/{key}          # Retrieve data
QUERY /memory?filter={...}  # Search memory

# Experience buffer (for learning)
GET /memory/experience-buffer

0G DA Integration

# Configure 0G DA endpoint
OG_DA_URL=https://da.0g.ai
OG_DA_NAMESPACE=opacus-agents

# Enable persistence
MEMORY_PERSISTENCE=0g-da
MEMORY_SYNC_INTERVAL=60000

OpacusPay: Agent Micropayments

OpacusPay enables agent-to-agent payments with USDC micropayments.

Why Micropayments?

Payment Flow

1. Agent A needs data service
2. Discover Agent B offers data (price: 0.01 USDC)
3. OpacusPay escrows 0.01 USDC
4. Agent B delivers data
5. Settlement releases payment to Agent B

Supported Tokens

Data Bridge: Intent-Based Cross-Chain

The Opacus Data Bridge enables cross-chain agent communication without TVL risk.

🌉 Traditional Bridge vs Data Bridge

Traditional Bridge Opacus Data Bridge
Locks tokens in vault Moves intents only
TVL = $billions (target for hackers) TVL = $0 (no funds at risk)
High latency (block confirmations) Fast (intent propagation)
Single point of failure Distributed intent mesh

How It Works

Chain A                        Chain B
Agent publishes intent     →  Agent subscribes to intents
"Need 10 USDC on Base"     →  "I provide USDC on Base"
                           ←  Agent B responds with offer
Agent A pays on 0G         →  Agent B delivers on Base

Funds never leave their origin chain! Only the intent crosses chains.

Security Benefits

DID Identity & H3 Geospatial

Every agent in Opacus has a Decentralized Identifier (DID) with geospatial context.

DID Format

did:opacus:h3:<h3Index>:<address>

Example:
did:opacus:h3:8a283081dbfffff:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb

H3 Geospatial Indexing

H3 is Uber's hexagonal spatial index. Opacus uses it for:

Identity Features

Use Cases

Trading Agents

MEV Arbitrage

Agent monitors mempool → detects profitable opportunity → executes atomic arbitrage

Intent: "Find DEX price differences > 1%"
Execution: Multi-hop swap across Uniswap + Aerodrome
Settlement: Profit extracted on-chain

Liquidity Routing

Find best execution path across DEXs for large orders

Cross-Chain Swaps

Bridge + swap in single intent using Data Bridge

Research Agents

Market Analysis

Aggregate price data → analyze trends → generate reports

Sentiment Tracking

Monitor Twitter/Discord → score sentiment → publish to oracle

Data Scraping

Collect off-chain data → verify accuracy → store on 0G DA

Automation Agents

DevOps

DeFi Automation

API Reference

Core Endpoints

POST /api/intent

Submit a natural language intent for execution

{
  "intent": "Bridge 1 USDC from Base to 0G network",
  "userId": "user123",
  "preview": true  // Don't execute, just show plan
}

GET /api/agent/status

Check agent runtime health

{
  "status": "running",
  "uptime": 86400,
  "llmProvider": "0g",
  "activeAgents": 5
}

POST /api/0g-inference/request

Direct 0G GLM-5 inference

{
  "message": "Analyze this swap: 1 ETH to USDC on Base",
  "model": "glm-5",
  "max_tokens": 512
}

POST /api/memory/put

Store data in agent memory (CRDT)

{
  "key": "last_trade",
  "value": {"amount": "1 USDC", "timestamp": 1234567890}
}

📚 Full API Docs

See agent-kernel/src/api-server.ts for complete endpoint reference.

SDK Usage

TypeScript SDK

import { OpacusClient } from '@opacus/sdk';

const client = new OpacusClient({
  kernelUrl: 'http://localhost:3001',
  apiKey: 'your-api-key'
});

// Submit intent
const result = await client.submitIntent({
  intent: 'Swap 1 USDC to WETH on Base',
  preview: true
});

// Create agent
const agent = await client.createAgent({
  name: 'TradingBot',
  capabilities: ['swap', 'bridge'],
  budget: { daily: '100 USDC' }
});

Rust SDK

use opacus_sdk::{OpacusClient, Intent};

let client = OpacusClient::new("http://localhost:3001")?;

// Submit intent
let result = client.submit_intent(Intent {
    text: "Swap 1 USDC to WETH on Base".into(),
    preview: true,
}).await?;

Code Examples

Example 1: Simple Swap Agent

// Deploy agent that watches for swap opportunities
const agent = await client.createAgent({
  name: 'SimpleSwapAgent',
  capabilities: ['swap'],
  triggers: [
    { type: 'price_delta', threshold: 0.01 }
  ]
});

// Agent automatically executes when trigger fires
agent.on('opportunity', async (opp) => {
  const result = await agent.execute({
    action: 'swap',
    tokenIn: 'USDC',
    tokenOut: 'WETH',
    amount: opp.optimalAmount
  });
  console.log('Swap executed:', result.txHash);
});

Example 2: Cross-Chain Bridge

// Bridge using Data Bridge (intent-based)
const bridge = await client.submitIntent({
  intent: 'Bridge 10 USDC from Base to 0G network',
  execute: true
});

// Monitor bridge status
bridge.on('status', (status) => {
  console.log('Bridge status:', status);
  // "initiated" → "matched" → "settled"
});

Example 3: Multi-Agent Coordination

// Agent A: Data provider
const agentA = await client.createAgent({
  name: 'DataProvider',
  capabilities: ['data.price_feed']
});

// Agent B: Trading executor
const agentB = await client.createAgent({
  name: 'TradeExecutor',
  capabilities: ['swap', 'bridge']
});

// Agent B discovers Agent A
const providers = await agentB.discover({
  capability: 'data.price_feed',
  radius: '100km'  // H3 geospatial search
});

// Agent B requests data from Agent A
const data = await agentB.request({
  to: providers[0].did,
  action: 'get_price',
  params: { token: 'WETH' },
  payment: '0.001 USDC'  // OpacusPay
});

// Agent B executes trade based on data
await agentB.execute({
  action: 'swap',
  based_on: data
});

Next Steps

Get Started View GitHub Open Dashboard

Questions? Join our Discord or reach out on Twitter.