File size: 2,479 Bytes
36a0f95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 = "0xB2c018C039F4Ae22BE08e30CFd94495fac0a6961"
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

@app.get("/")
async def root():
    return {"message": "PirateMap x402 is Online. POST /scan to find the gold."}

@app.post("/scan", response_model=MapResponse)
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)