Bonded-escrow marketplace for prompt → response between buyers and
local-LLM suppliers, settling on Vector (UTxO) via Aiken Plutus V3
validators. Lifecycle PostEscrow → Claim → Submit → Accept proven on
Vector testnet 2026-05-06; AcceptEscrow tx 125e3cfe…7dc100d distributes
payment + bonds per the validator's distribution rule.
Workspace layout (pnpm + TypeScript):
contracts/marketplace/ Aiken validators (advert + escrow) + plutus.json
packages/shared/ Tx-builders (lucid-evolution), CBOR codecs,
chain providers (mock / read-only / live Ogmios)
supplier/ OpenAI-compatible HTTP node (Ollama by default;
vLLM / llama.cpp / OpenRouter / OpenClaw all
swap-in via OLLAMA_URL); 202+poll chat handler
buyer/ Express + React SPA; server-side runs the full
chain lifecycle via /v1/submit-prompt and
/v1/accept; SPA never holds the buyer key
indexer/ Chain-follower (extends apex-dashboard pattern),
SSE event stream + REST queries
indexer-ui/ Operator dashboard (events + suppliers + escrow
lookup)
tests/ 1098 vitest unit + integration tests (10 skipped
under M1-F-D-defer for UPLC test plumbing)
deploy/testnet/ Per-service docker-compose for the Hetzner stack
docs/EXECUTIVE_SUMMARY.* Marp deck (PDF + PPTX) — 11 slides, mermaid
diagrams pre-rendered for portable export
docs/CLOUDFLARE_WAF_BYPASS.md CF Skip-rule runbook for /v1/* paths
docs/ARCHITECTURE.md canonical spec
Live demo (testnet, 2026-05-06):
https://mp-buyers.vector.testnet.apexfusion.org (buyer SPA)
https://mp-suppliers.vector.testnet.apexfusion.org (supplier API)
https://mp-indexer.vector.testnet.apexfusion.org (indexer + UI)
34 lines
1009 B
Python
34 lines
1009 B
Python
import asyncio
|
|
from .constants import MAX_UTXO_WAIT
|
|
|
|
|
|
def slot_to_posix_ms(context, slot):
|
|
gp = context.genesis_param
|
|
return (gp.system_start + slot * gp.slot_length) * 1000
|
|
|
|
|
|
async def wait_for_utxo(context, script_address, tx_hash, output_index=0):
|
|
elapsed = 0
|
|
while elapsed < MAX_UTXO_WAIT:
|
|
utxos = await context.async_utxos(str(script_address))
|
|
for utxo in utxos:
|
|
if (
|
|
str(utxo.input.transaction_id) == str(tx_hash)
|
|
and utxo.input.index == output_index
|
|
):
|
|
return utxo
|
|
await asyncio.sleep(4)
|
|
elapsed += 4
|
|
raise TimeoutError(
|
|
f"UTxO {tx_hash}#{output_index} not found at {script_address} "
|
|
f"after {MAX_UTXO_WAIT}s"
|
|
)
|
|
|
|
|
|
async def find_script_utxo(context, script_address, tx_hash):
|
|
utxos = await context.async_utxos(str(script_address))
|
|
for utxo in utxos:
|
|
if str(utxo.input.transaction_id) == str(tx_hash):
|
|
return utxo
|
|
return None
|