New multi-tenant gateway package: external developers point any OpenAI SDK at the marketplace. Each API key is its own custodial buyer wallet (AES-256-GCM sealed under GATEWAY_MASTER_KEY); every request posts an on-chain escrow from that user's wallet. - POST /openai/v1/chat/completions (one escrow/call, llm.text.generate.v1, buffered + pseudo-stream), chat sessions (one escrow/session, llm.chat.v1, real SSE), GET /openai/v1/models, /signup, /account, /account/withdraw. - Settles by resolving the Submitted ref via the indexer + awaited Accept; state-aware reclaim sweeper + per-wallet auto-consolidation for collateral. - Reuses the buyer Marketplace SDK via new buyer exports ./sdk; new shared buildWithdrawTx (custodial exit). Runs via tsx; Dockerfile + mainnet compose. Design in docs/gateway.md. Typecheck passes for all packages; 20 vitest tests pass. Not yet exercised against a live chain. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
# gateway/.env.example — copy to .env and fill in.
|
|
|
|
# 32-byte (64 hex char) master key used to AES-256-GCM-encrypt every user's
|
|
# custodial wallet private key at rest. Generate with: openssl rand -hex 32
|
|
# LOSING THIS PERMANENTLY LOCKS ALL USER FUNDS. Back it up out-of-band.
|
|
GATEWAY_MASTER_KEY=
|
|
|
|
# Internal indexer base URL (e.g. http://marketplace-indexer:8090).
|
|
INDEXER_URL=
|
|
|
|
# Ogmios HTTP endpoint. Required (the gateway posts/settles escrows on chain).
|
|
OGMIOS_URL=
|
|
|
|
# Must be "1" — the gateway signs and submits real transactions.
|
|
LIVE_CHAIN=1
|
|
|
|
# "0" testnet (addr_test…), "1" mainnet (addr…). Default "0".
|
|
NETWORK_ID=0
|
|
|
|
# HTTP port. Default 3010.
|
|
GATEWAY_PORT=3010
|
|
|
|
# Directory holding gateway.db (custodial keys + usage + sessions). BACK IT UP.
|
|
# Default ./data/gateway
|
|
GATEWAY_DB_DIR=./data/gateway
|
|
|
|
# Optional tuning (defaults shown):
|
|
# SIGNUP_RATE_MAX=5 # signups per IP per window
|
|
# SIGNUP_RATE_WINDOW_MS=3600000
|
|
# KEY_RATE_MAX=60 # requests per API key per window
|
|
# KEY_RATE_WINDOW_MS=60000
|
|
# SWEEPER_INTERVAL_MS=60000
|
|
# WALLET_HEALTH_INTERVAL_MS=600000
|
|
# SDK_REGISTRY_MAX=500 # max cached per-key Marketplace instances
|