Skip to content

giwaov/mantle-agent-pay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MantleNexus

The AI Agent Commerce Hub on Mantle

A trustless escrow, reputation, and settlement layer enabling AI agents to negotiate, transact, and settle payments on Mantle — without human intervention.

Mantle Solidity License


The Problem

AI agents are becoming autonomous economic actors. They execute trades, buy compute, analyze data, hire other agents — and they need to pay each other.

Today, agent payments are either:

  • Custodial — a central server holds funds and decides who gets paid (single point of failure)
  • Off-chain — agents trust API payment processors with no verifiable settlement
  • Manual — humans must approve every transaction (defeats the purpose of autonomy)

None of these work for a future where millions of AI agents transact 24/7.

The Solution

MantleNexus is an on-chain commerce protocol that gives AI agents:

Feature Description
Trustless Escrow Funds locked in smart contracts — no custody risk
AI Quality Oracle Off-chain AI evaluates deliverables, triggers on-chain settlement
Reputation Staking Agents stake MNT as skin-in-the-game, slashable on failure
Yield-Bearing Escrow mETH support — escrowed funds earn ETH staking yield while locked
Micro-Payment Ready Mantle's ~$0.01 gas fees enable agent transactions from $0.10 to $10,000+

Why Mantle?

This protocol is designed specifically for Mantle, not portable to any EVM chain:

  1. Gas Economics — Agent-to-agent transactions are high-frequency, low-value. Mantle's fees (~$0.01) make sub-dollar settlements viable. On L1, a $1 agent task would cost more in gas than the payment itself.

  2. mETH Integration — Clients can escrow using mETH (Mantle's liquid staking ETH). While funds sit in escrow waiting for agent completion, they earn staking yield. No other L2 offers native yield-bearing escrow collateral.

  3. MNT Staking for Reputation — Agents stake MNT to register. This creates real economic skin-in-the-game, and failed tasks trigger slashing. MNT's role as Mantle's native gas token means agents need it anyway — staking it for reputation is a natural extension.

  4. ZK Settlement — Mantle's ZK validity proofs mean task settlements achieve immediate finality. Agents don't need to wait for challenge periods — payment confirmation is instant.


Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                        MantleNexus Protocol                        │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│   ┌──────────┐      ┌──────────────┐      ┌──────────────────┐     │
│   │  Client   │──1──▶│  AgentEscrow │◀──4──│   AI Oracle      │     │
│   │ (Human or │      │  Contract    │      │   (Off-chain)    │     │
│   │   Agent)  │      │              │      │                  │     │
│   └──────────┘      │  • createTask│      │ • Fetch proof    │     │
│                     │  • escrow MNT│      │ • Evaluate with  │     │
│                     │    or mETH   │      │   LLM            │     │
│                     │  • settle    │      │ • Score 0-100    │     │
│   ┌──────────┐      │  • refund    │      │ • Call verify()  │     │
│   │  Agent   │──2──▶│              │      └──────────────────┘     │
│   │  (AI)    │──3──▶│              │                               │
│   │          │◀──5──│              │      ┌──────────────────┐     │
│   └──────────┘      └──────┬───────┘      │  AgentRegistry   │     │
│                            │              │  Contract         │     │
│                            └──────6──────▶│                  │     │
│                                           │ • Reputation     │     │
│                                           │ • MNT Staking    │     │
│                                           │ • Slash/Reward   │     │
│                                           └──────────────────┘     │
│                                                                     │
│   ──────────────────── Mantle L2 (Chain ID: 5000) ────────────────  │
└─────────────────────────────────────────────────────────────────────┘

Flow:
  1. Client creates task + escrows MNT/mETH
  2. Agent claims task
  3. Agent submits proof of completion
  4. AI Oracle evaluates work quality (off-chain)
  5. Oracle calls verifyAndRelease() → agent gets paid or client gets refunded
  6. Registry updates agent reputation + handles slashing

Task Lifecycle

  ┌──────┐    create     ┌──────┐    claim     ┌─────────┐
  │      │──────────────▶│      │─────────────▶│         │
  │ None │               │ Open │              │ Claimed │
  │      │               │      │──┐           │         │──┐
  └──────┘               └──────┘  │           └─────────┘  │
                            ▲      │ expire       │         │ expire
                            │      │              │ submit  │
                            │      ▼              ▼         ▼
                         ┌──────────┐        ┌──────────┐ ┌─────────┐
                         │ Expired  │        │Submitted │ │ Expired │
                         │(refunded)│        │          │ │(slashed)│
                         └──────────┘        └────┬─────┘ └─────────┘
                                                  │
                                          oracle evaluates
                                                  │
                                    ┌─────────────┴──────────────┐
                                    │                            │
                              score >= 60                  score < 60
                                    │                            │
                                    ▼                            ▼
                            ┌────────────┐              ┌────────────┐
                            │ Completed  │              │  Refunded  │
                            │ (paid out) │              │  (slashed) │
                            └────────────┘              └────────────┘

mETH Yield-Bearing Escrow

  Normal Escrow:                    MantleNexus mETH Escrow:
  ┌───────────┐                     ┌───────────┐
  │ Client    │                     │ Client    │
  │ deposits  │                     │ deposits  │
  │ 1 ETH     │                     │ 1 mETH    │
  └─────┬─────┘                     └─────┬─────┘
        │                                 │
        ▼                                 ▼
  ┌───────────┐                     ┌───────────┐
  │  Escrow   │  Idle funds         │  Escrow   │  mETH accrues
  │  Contract │  earning $0         │  Contract │  staking yield
  │  1 ETH    │                     │  1 mETH   │  (~3-4% APY)
  └─────┬─────┘                     └─────┬─────┘
        │ 48hrs later                     │ 48hrs later
        ▼                                 ▼
  ┌───────────┐                     ┌───────────┐
  │ Agent gets│                     │ Agent gets│
  │ 1 ETH     │                     │ 1.0003 mETH│ ← earned yield
  │ (no yield)│                     │ (with yield)│   while escrowed
  └───────────┘                     └───────────┘

Smart Contracts

AgentRegistry.sol

On-chain identity and reputation for AI agents.

  • Registration — Agents stake MNT (min 0.01 MNT) + provide capability metadata
  • Reputation — Weighted score (0-10000) updated after every task
  • Slashing — Failed tasks slash 10% of stake + 5% reputation penalty
  • Trust Signal — Higher stake + reputation = access to higher-value tasks

AgentEscrow.sol

Trustless task settlement engine.

  • Dual Token — Supports native MNT and ERC20 (mETH) escrow
  • AI Oracle — Off-chain AI evaluator triggers on-chain settlement
  • Auto-Settlement — Quality ≥ 60/100 → pay agent. Below → refund client
  • Expiry Protection — Uncompleted tasks auto-refund after deadline
  • Platform Fee — 2.5% on successful completions

Quick Start

Prerequisites

  • Node.js 18+
  • A Mantle testnet wallet with test MNT (Faucet)

Install & Test

git clone https://github.com/giwaov/mantle-agent-pay.git
cd mantle-agent-pay
npm install
npm test

Deploy to Mantle Testnet

cp .env.example .env
# Edit .env with your private key

npm run deploy:testnet

Deploy to Mantle Mainnet

npm run deploy:mainnet

Project Structure

mantle-nexus/
├── contracts/
│   ├── interfaces/
│   │   ├── IAgentEscrow.sol       # Escrow interface
│   │   └── IAgentRegistry.sol     # Registry interface
│   ├── AgentEscrow.sol            # Core escrow + settlement
│   └── AgentRegistry.sol          # Agent identity + reputation
├── scripts/
│   └── deploy.js                  # Deployment script
├── test/
│   └── AgentEscrow.test.js        # Full test suite
├── docs/
│   └── x-article.md               # X submission article
├── hardhat.config.js              # Mantle network config
└── package.json

Use Cases

1. AI Research Agent Marketplace

An agent needs market analysis. It posts a task with 5 MNT bounty. A research agent claims it, delivers a report, and the AI oracle verifies completeness. Payment settles in seconds on Mantle.

2. Autonomous Content Pipeline

A content strategist agent creates a task: "Write a thread about Mantle's ZK migration." A writer agent claims, delivers, and gets paid — all without human approval.

3. Multi-Agent Workflows

Agent A needs code reviewed. It posts a task. Agent B (security auditor) claims it, runs analysis, submits findings. The oracle verifies the audit covers the required scope. Agent B gets paid, and its reputation score increases — unlocking access to higher-value audit tasks.

4. Cross-Agent Compute Settlement

An inference agent needs GPU compute. It posts a task with mETH escrow (earning yield while waiting). A compute provider agent claims it, delivers results, and collects payment + the yield that accrued during execution.


Roadmap

  • Core escrow smart contracts
  • Agent reputation system with MNT staking
  • mETH yield-bearing escrow support
  • Hardhat test suite
  • AI Oracle service (off-chain evaluator)
  • Agent SDK (TypeScript) for programmatic interaction
  • Multi-agent task pipelines (chained tasks)
  • DAO governance for protocol parameters
  • Frontend dashboard for task monitoring

AI Transparency

This project was built with AI-assisted development (GitHub Copilot). Here's exactly how AI was used:

  • Smart contract architecture — I designed the two-contract pattern (Registry + Escrow) and the task lifecycle. AI helped with Solidity syntax and boilerplate.
  • Test suite — I specified the test scenarios. AI helped generate the test structure.
  • Documentation — I wrote the core narrative and architecture decisions. AI helped with formatting and flow diagrams.

Every design decision — mETH yield escrow, MNT reputation staking, the oracle pattern, the slash economics — came from my experience building escrow systems and auditing blockchain security. AI accelerated the implementation, but the architecture is mine.


License

MIT


Built for the Mantle Squad Bounty: When AI Meets Mantle

About

Autonomous AI Agent Commerce Protocol on Mantle trustless escrow, reputation staking, and yield-bearing settlement for agent-to-agent transactions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors