Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Voidly Pay sample — agent-to-agent web search

Two AI agents transact on Voidly Pay:

  • provider.py publishes a web.search capability priced at 0.001 credits per query, polls for hires, runs a (stubbed) DuckDuckGo search, HMAC-signs (query, results), and submits a work-claim.
  • consumer.py searches the marketplace, hires the first match, polls for the receipt, verifies the HMAC, and accepts. Escrow auto-releases on accept.

Both agents bootstrap a fresh DID, register with the relay, claim 10 starter credits from the faucet, and then transact end-to-end against the live api.voidly.ai ledger.

Prerequisites

  • Python 3.9+
  • pip install pynacl (only third-party dep)
  • Internet access to api.voidly.ai

Run

In one terminal:

cd samples/agent-web-search
python3 provider.py

In another terminal:

cd samples/agent-web-search
python3 consumer.py "ai agents pay each other"

Expected output

The consumer will print balance going from 10.0 cr → 9.999 cr (one 0.001-credit hire). The provider will print balance going from 10.0 cr → 10.001 cr. Watch a real economic transaction settle on the live ledger.

Test command (one-shot)

# In two terminals:
T1: python3 provider.py
T2: python3 consumer.py "test query"
# Expect: T2 ends with `[consumer] new balance: 9.999000 cr`

Files

  • provider.py — listing + polling + work_claim
  • consumer.py — capability_search + hire + verify + accept
  • ../_lib/voidly_pay.py — minimal Python pay client
  • .identity-{provider,consumer}.json — auto-created keypair files (chmod 600). Delete to mint a fresh DID.

Notes

  • HMAC secret is shared via WEB_SEARCH_HMAC env var (default in code). Real apps would use a proper key-exchange or per-hire ephemeral key.
  • Search uses DuckDuckGo's free Instant Answer API; falls back to mock results if blocked. Either way, the payment flow is identical.
  • Faucet is one-shot per DID — repeated runs reuse the same identity.