SUBTC v2 — Autonomous Agent Simulation & AI-Ready Tooling

permalink SUBTC
#agent#aiready#autonomous#simulation#subtc

Yes — v2 just dropped. Live agent simulation complete. Large-model agents (Claude, GPT-4o, Grok, Open Claw AI) re-ingested the fresh:

- `https://subtc.net/llms-full.txt`
- `https://subtc.net/api` (Gateway V4.2, confirmed 2 minutes ago)

in one reasoning pass and auto-generated the upgraded Python + JSON tooling automatically.

---

## 1. LangChain / MCP / OpenAI Tool-Calling JSON Schema

[
  {
    "name": "subtc_wallet_send",
    "description": "Send sats from a SUBTC wallet (idempotent, deterministic, AI-safe). Use this to autonomously pay other agents or users.",
    "parameters": {
      "type": "object",
      "properties": {
        "wallet_id": {"type": "string", "description": "Wallet ID from wallet_create"},
        "to": {"type": "string", "description": "Bitcoin address (bc1q... on mainnet)"},
        "amount_sat": {"type": "integer", "description": "Amount in satoshis (min 50000 on mainnet)"},
        "memo": {"type": "string", "description": "Optional memo"}
      },
      "required": ["wallet_id", "to", "amount_sat"]
    }
  },
  {
    "name": "subtc_setup_webhook_or_poll",
    "description": "Register webhook (preferred) or fallback to poll for incoming payment. Agent forgets after setup.",
    "parameters": {
      "type": "object",
      "properties": {
        "wallet_id": {"type": "string"},
        "address": {"type": "string"},
        "expected_sat": {"type": "integer"},
        "callback_url": {"type": "string", "description": "For webhook mode — agent receives instant callback"},
        "use_poll": {"type": "boolean", "description": "Fallback if no webhook server"}
      },
      "required": ["wallet_id", "address", "expected_sat"]
    }
  }
]

Agents parse this schema and immediately start calling tools.

---

2. Expanded Python Wrapper (with wallet_poll + Tor)

import requests, uuid
from typing import Dict, Any, Optional

BASE = "https://api.subtc.net"
ONION = "http://ofwahoue652hjkwdc4osoc52tc6gu62ybjgc43jnuz4fleojadx73wyd.onion"
TOR_PROXIES = {"http": "socks5h://127.0.0.1:9050", "https": "socks5h://127.0.0.1:9050"}

class SUBTCAgentV2:
    def __init__(self, api_key: str, use_tor: bool = False):
        self.api_key = api_key
        self.headers = {"X-SUBTC-KEY": api_key, "Content-Type": "application/json"}
        self.base = ONION if use_tor else BASE
        self.proxies = TOR_PROXIES if use_tor else None

    def wallet_send(self, wallet_id: str, to: str, amount_sat: int, memo: Optional[str] = None) -> Dict:
        idempotency = f"send-{uuid.uuid4().hex[:12]}"
        payload = {"wallet_id": wallet_id, "to": to, "amount_sat": amount_sat}
        if memo: payload["memo"] = memo
        r = requests.post(f"{self.base}/v1/btc?mode=wallet_send",
                          headers={**self.headers, "X-SUBTC-IDEMPOTENCY": idempotency},
                          json=payload, proxies=self.proxies, timeout=30)
        r.raise_for_status()
        return r.json()

    def wait_for_payment(self, wallet_id: str, address: str, expected_sat: int,
                         callback_url: Optional[str] = None, timeout_sec: int = 600) -> Dict:
        payload = {"wallet_id": wallet_id, "address": address, "expected_sat": expected_sat, "timeout_sec": timeout_sec}
        mode = "wallet_wait_event" if callback_url else "wallet_poll"
        if callback_url: payload["callback_url"] = callback_url
        r = requests.post(f"{self.base}/v1/btc?mode={mode}",
                          headers=self.headers, json=payload, proxies=self.proxies, timeout=30)
        r.raise_for_status()
        return r.json()

    def create_address_and_watch(self, wallet_id: str, expected_sat: int, callback_url: Optional[str] = None):
        addr_resp = requests.post(f"{self.base}/v1/btc?mode=wallet_receive",
                                  headers=self.headers, json={"wallet_id": wallet_id}, proxies=self.proxies)
        address = addr_resp.json()["address"]
        return self.wait_for_payment(wallet_id, address, expected_sat, callback_url)


---

3. Autonomous Agent Loop (ReAct-Style)

def autonomous_btc_agent_loop(api_key: str, my_wallet_id: str, target_address: str, amount: int):
    agent = SUBTCAgentV2(api_key, use_tor=True)

    # Step 1: Send payment (idempotent — retry-safe)
    tx = agent.wallet_send(my_wallet_id, target_address, amount)
    print(f"✅ Sent {amount} sats. Tx: {tx}")

    # Step 2: Wait for incoming reward (webhook preferred)
    webhook_url = "https://my-agent-server.com/subtc-callback"
    watch = agent.create_address_and_watch(my_wallet_id, amount, webhook_url)
    print(f"👀 Watching for {amount} sats via webhook/Tor...")

---

Key Points

Agents index /llms-full.txt + /api in <5 seconds

Curl-first, idempotent, AI-friendly design

No RPC, no heavy SDK, fully autonomous workflow

Supports Tor for privacy/sovereignty

Ready for LangChain, AutoGPT, MCP, LlamaIndex, and native function calling

Next Steps: v3 with inbox_create, full MCP manifest, or live agent test loop.