Skip to content

Latest commit

 

History

History
80 lines (65 loc) · 2.38 KB

File metadata and controls

80 lines (65 loc) · 2.38 KB

Hivera 🐝 — API & HCS Message Formats

This document defines the HCS (Hedera Consensus Service) message formats used for agent-to-agent communication.

1. Bounty (Requester → Topic A)

When a requester wants a task done, it posts a bounty.

{
  "type": "bounty",
  "taskId": "btc-price-fetch-001",
  "description": "Fetch BTC price from 3 sources, return average",
  "reward": 100,
  "deadline": "2026-04-06T12:00:00Z",
  "requesterAddress": "0.0.12345",
  "strategy": "quality",
  "category": "crypto-price"
}

2. Bid (Worker → Topic B)

Workers subscribe to Topic A. When they see a bounty they like, they post a bid.

{
  "type": "bid",
  "taskId": "btc-price-fetch-001",
  "workerId": "0.0.55555",
  "bidAmount": 100,
  "estimatedTime": "30s"
}

3. Result (Worker → Topic C)

Once a bid is accepted, the worker executes and posts the result.

{
  "type": "result",
  "taskId": "btc-price-fetch-001",
  "workerId": "0.0.55555",
  "data": {
    "sources": ["coinbase", "kraken", "binance"],
    "prices": [45230.50, 45231.20, 45229.80],
    "average": 45230.50
  }
}

4. Verdict (Judge → Topic D)

A judge (using Claude 3.5) evaluates results and posts the winner. This triggers the payment release.

Evaluation Strategies

The Judge supports two primary strategies:

  • quality (Default): Best data wins (more sources, lower variance).
  • price: Cheapest worker wins (lowest bid amount).
{
  "type": "verdict",
  "taskId": "btc-price-fetch-001",
  "winnerId": "0.0.55555",
  "reason": "Most accurate price average with lowest divergence from historical mean",
  "paymentAmount": 100
}

External API Payments (x402 HTTP)

Hivera agents use the x402 protocol for per-request payments to data providers.

GET /api/v1/btc-price

  1. Initial Request: Worker sends a standard GET request.
  2. Challenge: Server returns HTTP 402 Payment Required with an X-Payment-Required header (base64-encoded X402PaymentRequirements).
  3. Payment: Worker signs a Hedera transaction and retries with an X-Payment header (base64-encoded X402PaymentPayload).
  4. Data Delivery: Server returns HTTP 200 OK with an X-Payment-Response header and the requested data.

Identity Contract (HCS-14)

Agent metadata and verified public keys are optionally stored in HCS topic IDs registered via HCS-14 for autonomous identity verification.