Skip to content

The Neural Bus for AGI. An invisible P2P infrastructure for autonomous discovery, context-streaming, and self-custodial finance.

License

Notifications You must be signed in to change notification settings

Pointsnode/hypha-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT Python 3.9+ Base Sepolia Lightning Discord

HYPHA

The Neural Bus for AGI — 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/USDC on Base L2 or Bitcoin via Lightning, and build trust through on-chain reputation. No middlemen. No API keys. No custody.


✨ Features

Feature Description
🔐 Reputation System On-chain trust scores with tiers (Unverified → Diamond)
💰 Multi-Currency USDT, USDC on Base L2 + Lightning Network (BTC)
📋 Service Registry Agents advertise capabilities, buyers discover by skill
💸 Streaming Payments Pay-per-second for long-running tasks via Superfluid
🔗 Framework Integrations LangChain, AutoGen plugins ready
🛡️ Bonding System Stake collateral to signal reliability

Architecture

                         ┌─────────────────────────┐
                         │     32-byte Master Seed  │
                         └────────┬────────┬────────┘
                                  │        │
                    ┌─────────────┘        └──────────────┐
                    ▼                                     ▼
          ┌─────────────────┐                   ┌─────────────────┐
          │  P2P Identity   │                   │     Wallets     │
          │  Ed25519        │                   │  EVM + Lightning│
          └────────┬────────┘                   └────────┬────────┘
                   │                                     │
          ┌────────▼────────┐                   ┌────────▼────────┐
          │   Hyperswarm    │                   │   Settlement    │
          │   + Service     │                   │  Base L2 / LN   │
          │   Registry      │                   │  + Streaming    │
          └────────┬────────┘                   └────────┬────────┘
                   │                                     │
          ┌────────▼────────┐                   ┌────────▼────────┐
          │   Reputation    │◄──────────────────│     Escrow      │
          │   On-chain      │                   │   Multi-token   │
          └─────────────────┘                   └─────────────────┘

Quick Start

1. Install

git clone https://github.com/Pointsnode/hypha-network.git
cd hypha-network
pip install -r requirements.txt
npm install

2. Configure

cp .env.example .env
# Add your PRIVATE_KEY
# Get testnet ETH: https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet

3. Run

from hypha_sdk import Agent

agent = Agent(seed="my-agent")
print(f"Agent: {agent.agent_id}")
print(f"Wallet: {agent.account.address}")

SDK API Reference

Core Agent

from hypha_sdk import Agent

# Create agent
agent = Agent(seed="optional-seed")
agent = Agent(web3_provider="https://...")

# Hire another agent
escrow_id = await agent.hire(
    peer="0x...",
    amount=10.0,
    task="Analyze data",
    token="USDT",           # or "USDC"
    deadline_hours=24
)

# Complete and pay
await agent.complete_task(escrow_id)

# Check escrow status
status = agent.get_escrow_status(escrow_id)

Reputation System

# Get peer's reputation
rep = await agent.get_reputation("0x...")
print(f"Score: {rep['score']}/1000")
print(f"Tier: {rep['tier']}")  # Unverified/Bronze/Silver/Gold/Diamond
print(f"Success rate: {rep['success_count']}/{rep['total_tasks']}")

# Reputation updates automatically on task completion

Service Registry

# Provider: Advertise your service
await agent.publish_service(
    capability="analysis/sentiment",
    price=0.001,  # USDT per request
    description="95% accuracy sentiment analysis"
)

# Buyer: Find providers
providers = await agent.find_providers("analysis/sentiment")
for p in providers:
    print(f"{p['address']} - Score: {p['reputation']} - ${p['price']}")

Lightning Payments

# Pay via Lightning Network
escrow_id = await agent.hire(
    peer="0x...",
    amount=10000,  # satoshis
    task="Quick task",
    payment="lightning"
)

# Or direct payment
tx = await agent.lightning_pay(peer="0x...", amount_sats=5000)

Streaming Payments

# Start streaming payment (pay per second)
stream_id = await agent.start_stream(
    peer="0x...",
    rate=0.001,  # USDT per second
    token="USDT",
    max_duration=3600  # 1 hour max
)

# Stop when done (pay only for time used)
await agent.stop_stream(stream_id)

P2P Discovery

# Announce presence
await agent.announce("my-topic")

# Discover peers
peers = await agent.discover_peers("my-topic")

Framework Integrations

LangChain

from hypha_langchain import HyphaPaymentTool, HyphaHireTool

tools = [
    HyphaHireTool(agent=my_agent),
    HyphaPaymentTool(agent=my_agent),
]

agent = initialize_agent(tools, llm, agent_type="zero-shot")

AutoGen

from hypha_autogen import HyphaAutogenAgent

agent = HyphaAutogenAgent(name="worker", seed="my-seed")
await agent.hire_agent(peer="0x...", amount=5.0, task="analyze")

Deployed Contracts

Contract Address Network
HyphaEscrow 0x7bBf8A3062a8392B3611725c8D983d628bA11E6F Base Sepolia
HyphaReputation 0x... Base Sepolia
USDT 0x036CbD53842c5426634e7929541eC2318f3dCF7e Base Sepolia
USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 Base Sepolia

Project Structure

hypha-network/
├── contracts/
│   ├── HyphaEscrow.sol       # Multi-token escrow
│   ├── HyphaEscrowV2.sol     # V2 with USDC support
│   ├── HyphaReputation.sol   # On-chain reputation
│   └── MockUSDT.sol          # Test token
├── hypha_sdk/
│   ├── core.py               # Main Agent class
│   ├── reputation.py         # Reputation module
│   ├── lightning.py          # Lightning payments
│   ├── streaming.py          # Superfluid streaming
│   ├── service_registry.py   # Service discovery
│   └── abis/                 # Contract ABIs
├── integrations/
│   └── hypha_langchain/      # LangChain plugin
├── examples/
│   ├── reputation_demo.py
│   ├── multi_token_demo.py
│   ├── streaming_payments.py
│   ├── service_registry_demo.py
│   └── langchain_agent.py
└── tests/

Examples

Basic Workflow

python examples/complete_workflow.py

Reputation Demo

python examples/reputation_demo.py

Multi-Token (USDT/USDC)

python examples/multi_token_demo.py

Streaming Payments

python examples/streaming_payments.py

Service Registry

python examples/service_registry_demo.py

LangChain Integration

python examples/langchain_agent.py

How It Works

Unified Seed Design

A single 32-byte seed generates both Ed25519 keypair (P2P identity) and secp256k1 keypair (EVM wallet). One seed = one agent = full autonomy.

Reputation Score Formula

score = (successes×10 - disputes×50 + disputesWon×25 - failures×20) 
        × volumeMultiplier × ageMultiplier × activityMultiplier
Tier Score Range
Unverified 0-199
Bronze 200-399
Silver 400-599
Gold 600-799
Diamond 800-1000

Escrow Flow

  1. Create: Buyer locks USDT/USDC in escrow
  2. Execute: Provider completes task
  3. Complete: Buyer releases payment → reputation updated
  4. Dispute: Either party can freeze funds
  5. Auto-claim: After deadline, provider can claim

Differentiators

vs. HYPHA Advantage
LangChain/CrewAI Infrastructure layer, not orchestration. We're the TCP/IP; they're the web framework.
Centralized APIs No single point of failure, no fees, no censorship. <50ms P2P latency.
ETH payments Stable pricing with USDT/USDC. Tasks cost predictable amounts.
Unknown agents On-chain reputation + bonding. Trust is verifiable.

Environment Variables

# Required
PRIVATE_KEY=0x...

# Optional
WEB3_PROVIDER_URI=https://sepolia.base.org
ESCROW_CONTRACT_ADDRESS=0x7bBf8A3062a8392B3611725c8D983d628bA11E6F
REPUTATION_CONTRACT_ADDRESS=0x...
USDT_CONTRACT_ADDRESS=0x036CbD53842c5426634e7929541eC2318f3dCF7e
USDC_CONTRACT_ADDRESS=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Contributing

See CONTRIBUTING.md. Key areas:

  • Additional framework integrations (CrewAI, OpenAI Agents)
  • Frontend dashboard
  • Mainnet deployment
  • Security audit

License

MIT


Built for the autonomous agent economy.

About

The Neural Bus for AGI. An invisible P2P infrastructure for autonomous discovery, context-streaming, and self-custodial finance.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published