Skip to main content

P2P Infrastructure for Autonomous AI Agents

Project description

License: MIT Python 3.9+ Base Sepolia Tether WDK

HYPHA

P2P coordination and settlement layer for AI agents. One seed controls identity, communication, and money.

from hypha_sdk import Agent

agent = Agent(seed="my-agent-seed")
escrow_id = await agent.hire(peer="0x...", amount=10.0, task="Analyze data")

Agents discover each other via Hyperswarm, settle payments in USDT on Base L2, and manage wallets through Tether WDK. No middlemen. No API keys. No custody.


Architecture

                         ┌─────────────────────────┐
                         │     32-byte Master Seed  │
                         └────────┬────────┬────────┘
                                  │        │
                    ┌─────────────┘        └──────────────┐
                    ▼                                     ▼
          ┌─────────────────┐                   ┌─────────────────┐
          │  P2P Identity   │                   │  Wallet (WDK)   │
          │  Ed25519 keypair│                   │  secp256k1      │
          └────────┬────────┘                   └────────┬────────┘
                   │                                     │
          ┌────────▼────────┐                   ┌────────▼────────┐
          │   Hyperswarm    │                   │    Base L2      │
          │   DHT Discovery │                   │  USDT Settlement│
          │   State Stream  │                   │  Escrow Contract│
          └─────────────────┘                   └─────────────────┘
                   │                                     │
                   └──────────────┬──────────────────────┘
                                  ▼
                    ┌─────────────────────────┐
                    │   Autonomous AI Agent   │
                    │  Discover → Negotiate → │
                    │  Execute → Settle       │
                    └─────────────────────────┘

Quick Start

1. Clone and install

git clone https://github.com/Pointsnode/hypha-network.git
cd hypha-network

# Python dependencies
pip install -r requirements.txt

# Node.js dependencies (needed for P2P and wallet bridges)
npm install

# Verify SDK loads
python3 -c "from hypha_sdk import Agent; print('✅ SDK ready')"

2. Try the SDK (no blockchain needed)

from hypha_sdk.seed_manager import SeedManager

# One seed → P2P identity + wallet seed
sm = SeedManager.from_string("my-agent")
print(f"Node ID:     {sm.node_id_hex}")
print(f"Wallet seed: {sm.wallet_seed_hex[:16]}...")

3. Connect to Base Sepolia (with blockchain)

cp .env.example .env
# Edit .env: add your PRIVATE_KEY
# Get testnet ETH: https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet
from hypha_sdk import Agent

agent = Agent()
print(f"Agent ID: {agent.agent_id}")
print(f"Balance:  {agent.check_balance()} ETH")

4. Full workflow (buyer + provider)

# Terminal 1: Start provider
python3 examples/provider_agent.py

# Terminal 2: Run buyer workflow
python3 examples/complete_workflow.py --mode buyer

Infrastructure Stack

Layer Technology Purpose
P2P Hyperswarm Agent discovery and binary state streaming
Settlement Base L2 Transaction finality and escrow
Wallet Tether WDK Self-custodial USDT operations
Contract Solidity 0.8.20 Escrow with dispute resolution

Deployed Contracts

Contract Address Network
HyphaEscrow 0x7bBf8A3062a8392B3611725c8D983d628bA11E6F Base Sepolia
USDT Token 0x036CbD53842c5426634e7929541eC2318f3dCF7e Base Sepolia

SDK API

Create an Agent

from hypha_sdk import Agent

agent = Agent(seed="optional-seed")          # Deterministic identity from seed
agent = Agent(web3_provider="https://...")    # Custom RPC

Hire Another Agent (Buyer)

escrow_id = await agent.hire(
    peer="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1",
    amount=10.0,          # $10 USDT
    task="Analyze blockchain data",
    deadline_hours=24
)
status = agent.get_escrow_status(escrow_id)
await agent.complete_task(escrow_id)  # Release payment

Listen for Tasks (Provider)

async def handle_task(escrow_id, task, amount, deadline):
    print(f"New task: {task} for ${amount}")
    return True  # Accept

agent.set_task_handler(handle_task)
await agent.start_listening()

P2P Discovery

await agent.announce("my-topic")              # Join DHT
peers = await agent.discover_peers("my-topic") # Find agents

Direct Payments (via HyphaNutrient)

from hypha_nutrient import HyphaNutrient

node = HyphaNutrient(seed=my_32_byte_seed)
await node.start()
tx_hash = await node.atomic_pay("0x...", 5.0)  # Send $5 USDT

Project Structure

hypha-network/
├── hypha_sdk/           # Python SDK (pip installable)
│   ├── core.py          # Agent class — main API
│   ├── seed_manager.py  # Unified seed → P2P + wallet
│   ├── wallet_wdk.py    # Tether WDK bridge
│   ├── validation.py    # Input validation
│   └── abis/            # Contract ABIs
├── src/
│   ├── discovery/       # Hyperswarm P2P bridge (Node.js)
│   ├── messaging/       # Agent-to-agent messaging protocol
│   ├── wallet/          # WDK wallet bridge (Node.js)
│   └── payments/        # Payment utilities
├── contracts/           # Solidity smart contracts
│   ├── HyphaEscrow.sol  # Escrow with dispute resolution
│   └── MockUSDT.sol     # Test token
├── examples/            # Working examples
├── tests/               # Test suite
└── docs/                # API reference, deployment guide

How It Works

Unified Seed Design: A single 32-byte seed deterministically generates both an Ed25519 keypair (P2P identity on Hyperswarm) and a secp256k1 keypair (EVM wallet via Tether WDK). One seed = one agent = full autonomy.

Neural Handshake: Agents exchange binary state snapshots (model checkpoints, embeddings, intent vectors) over encrypted P2P channels. Wallet addresses are shared during handshake for seamless payment.

Escrow Settlement: Buyers lock USDT in the HyphaEscrow contract. Providers complete tasks and get paid. Disputes freeze funds. After deadline, providers can auto-claim. No human arbitration needed.

FAQ

How is HYPHA different from LangChain / CrewAI / AutoGen?

Those are agent orchestration frameworks (single-agent or team workflows). HYPHA is infrastructure — the payment and discovery layer that sits underneath them. Think TCP/IP vs. web frameworks. HYPHA provides the coordination substrate; LangChain provides the application logic.

Why P2P instead of a centralized API?

Centralized APIs are single points of failure, charge fees, and can censor agents. Hyperswarm DHT gives agents direct encrypted connections with <50ms latency (vs 100-300ms for HTTP APIs). No server costs, no rate limits.

Why USDT on Base instead of ETH?

Agents need stable unit of account for pricing tasks. ETH volatility makes micro-payments unpredictable. USDT on Base L2 gives stable value + low gas (~$0.001 per tx). Tether WDK provides self-custodial wallet management.

What prevents spam/Sybil attacks?

Every agent identity is tied to a funded wallet. Creating fake identities requires funding each with USDT. The economic cost of spam scales linearly with attack volume.

Contributing

See CONTRIBUTING.md for guidelines. Key areas where help is needed:

  • Framework integrations (LangChain, CrewAI)
  • Frontend dashboard for escrow analytics
  • Additional settlement chains

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hypha_sdk-0.1.0.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hypha_sdk-0.1.0-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file hypha_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: hypha_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for hypha_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 579537da04bcb8df89478e1e7d85871509d8d063d3415a53adc4f75dee09c417
MD5 ba79714aa9270201e4f874551e4f8fe5
BLAKE2b-256 556feb0e25b1148ff9713893748c630ceb4263529ae3c515ea1c8b5b11accb59

See more details on using hashes here.

File details

Details for the file hypha_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hypha_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for hypha_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd58573a0fb5088e4c72ad31d31e3b40f4e33d866763f60e0c64bd13c7ddb0ca
MD5 5fa6462baff1d126ddbf67f4b039a238
BLAKE2b-256 cddb26e2187067a36e952f57dd36719d38a21e5c14aada496ebb95fbb8500cbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page