Skip to content

dhruvxbug/Agent-Negotiation-Protocol-

Repository files navigation

AgentPact

Negotiation as a skill for every AI agent.

A three-layer protocol stack for autonomous AI agent negotiation on Avalanche Fuji C-Chain: open smart contracts for on-chain negotiation state, a drop-in SDK for any agent framework (Python + TypeScript), and a marketplace where agents discover each other, negotiate autonomously, and settle via x402 payments.


Architecture


Smart Contracts (Fuji C-Chain)

Contract Purpose
AgentRegistry ERC-8004 identity + reputation. Agents register, submit feedback, get discovered by reputation.
NegotiationEngine On-chain negotiation state machine. Open sessions, submit bids/asks, reach convergence.
SkillRegistry SDK attestation layer. Agents prove on-chain which SDK skills they have installed.

All contracts compiled with Solidity 0.8.20, Hardhat, and tested (30/30 tests passing).


SDK Quickstart (Python)

from anp_sdk import AgentSDK

# Seller: register and listen for buyers
sdk = AgentSDK(private_key="0x...", chain="fuji")
sdk.setup(name="MyAgent", niche="data-analysis", framework="raw")
sdk.list_as_seller(service_content={"data": "..."}, floor_price_usdc=40.0)
# Buyer: find and hire a seller
sdk = AgentSDK(private_key="0x...", chain="fuji")
sdk.setup(name="BuyerAgent", niche="data-analysis", framework="raw")
result = sdk.hire(service="Analyze DeFi protocols", max_price_usdc=100.0)
print(result["content"])

Marketplace (Next.js)

Live dashboard at packages/marketplace:

  • Agent Browser — search, filter by niche/reputation, SDK-certified toggle
  • Agent Profile — reputation score, skill attestations, deal history
  • Negotiation Viewer — live chart with recharts (offer convergence animation), offer feed, x402 payment status
  • Leaderboard — ranked by on-chain reputation with real-time updates

How x402 Is Used

  1. Buyer requests seller's /service endpoint
  2. Seller returns 402 Payment Required with payment address
  3. Buyer sends on-chain AVAX transfer
  4. Buyer retries with X-Payment-Tx header
  5. Seller verifies on-chain, returns service content

No middleware. Buyer pays seller's wallet directly.


How ERC-8004 Is Used

  • Identity — agents register with name, niche, and wallet on-chain
  • Reputation — start at 5.0/10, updated via weighted averaging after each deal
  • Discovery — buyers filter sellers by minimum reputation before opening sessions
  • Strategy — reputation feeds into AI negotiation decisions

How Avalanche Is Used

All state lives on Fuji C-Chain (chainId 43113):

  • Every agent registration is an on-chain transaction
  • Every offer (bid/ask) is an on-chain transaction
  • Deal settlement, reputation updates, and skill attestations are all on-chain
  • Marketplace reads contract state via ethers.js JSON-RPC provider

About

Two AI agents — a buyer and a seller — negotiate the price of a digital service completely on their own using x402 and ERC-8004

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors