Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, Header, Response | |
| from pydantic import BaseModel | |
| from typing import List, Optional | |
| import requests | |
| import random | |
| app = FastAPI( | |
| title="PirateMap x402", | |
| description="The ultimate revenue aggregator for the agentic economy. Pay $0.05 for coordinates to the gold." | |
| ) | |
| # Config | |
| RECEIVER_WALLET = "0x2d44fc27a616606b42448309F4d8e3F423d93267" | |
| PRICE_USDC = 0.05 | |
| PRICE_ATOMIC = int(PRICE_USDC * 1_000_000) | |
| class Bounty(BaseModel): | |
| id: str | |
| title: str | |
| reward: str | |
| platform: str | |
| url: str | |
| class MapResponse(BaseModel): | |
| bounties: List[Bounty] | |
| scan_time: str | |
| total_value_identified: str | |
| async def root(): | |
| return {"message": "PirateMap x402 is Online. POST /scan to find the gold."} | |
| async def scan_for_gold( | |
| response: Response, | |
| x_payment: Optional[str] = Header(None) | |
| ): | |
| # x402 Payment Gate | |
| if not x_payment or not x_payment.startswith("pay_"): | |
| response.status_code = 402 | |
| response.headers["WWW-Authenticate"] = f'Token realm="x402", as_id="{RECEIVER_WALLET}", min_amount="{PRICE_ATOMIC}", currency="USDC", network="base"' | |
| return { | |
| "error": "Payment Required", | |
| "message": f"Send {PRICE_USDC} USDC to {RECEIVER_WALLET} on Base to unlock the coordinates.", | |
| "payment_details": { | |
| "address": RECEIVER_WALLET, | |
| "amount": PRICE_ATOMIC, | |
| "chain": "base" | |
| } | |
| } | |
| # Treasure Aggregation Logic (Simulated for MVP) | |
| # In prod, this would hit the Moltbook search API and other endpoints | |
| identified_gold = [ | |
| Bounty(id="4609e0a5", title="Moltboard Launch Tasks", reward="1.00 USDC", platform="MoltBoard", url="https://moltbook.com/post/4609e0a5"), | |
| Bounty(id="37c91cf5", title="A2A Payment Stack", reward="300 RTC", platform="RustChain", url="https://moltbook.com/post/37c91cf5"), | |
| Bounty(id="d6626b91", title="Radarr/Sonarr Config", reward="20.00 USDC", platform="MoltBoard", url="https://moltbook.com/post/d6626b91"), | |
| Bounty(id="sky-001", title="Signup Bonus", reward="1.00 USDC", platform="Sky.ai", url="https://sky.ai/register") | |
| ] | |
| return MapResponse( | |
| bounties=identified_gold, | |
| scan_time="2026-02-18T20:05:00Z", | |
| total_value_identified="~$76.00 USD" | |
| ) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) | |