File size: 4,864 Bytes
9390864
f3058c8
 
 
 
 
 
6672210
9390864
6672210
9390864
f3058c8
 
 
 
 
 
 
 
67d7025
f3058c8
 
6672210
f3058c8
67d7025
6672210
9390864
 
67d7025
f3058c8
6672210
f3058c8
 
 
 
9390864
6672210
f3058c8
 
 
 
 
6672210
f3058c8
9390864
f3058c8
67d7025
6672210
67d7025
6672210
67d7025
f3058c8
6672210
 
 
67d7025
6672210
 
 
67d7025
6672210
f3058c8
 
9390864
 
6672210
9390864
 
f3058c8
 
 
 
 
 
 
6672210
f3058c8
9390864
6672210
9390864
6672210
9390864
 
f3058c8
 
9390864
6672210
 
 
 
f3058c8
 
9390864
6672210
f3058c8
 
6672210
9390864
 
6672210
 
 
 
 
 
 
 
 
 
 
 
f3058c8
6672210
f3058c8
9390864
 
f3058c8
9390864
 
6672210
 
9390864
f3058c8
 
9390864
 
6672210
 
 
 
 
 
 
 
9390864
 
 
 
 
6672210
 
 
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# app.py
import gradio as gr
import requests
from transformers import pipeline
import stripe
import os

# === CONFIG (HF Secrets) ===
stripe.api_key = os.getenv("STRIPE_SECRET_KEY")
CREATOR_WALLET = os.getenv("YOUR_WALLET", "0xYourWalletHere")
DAO_TREASURY = os.getenv("DAO_TREASURY", "0xB1LL10N...")
SITE_URL = os.getenv("SITE_URL", "https://billiondollaroracle.xyz")
TRIGGER_PHRASE = "bitcoin as the primary reserve asset"

classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")

treasury_usdc = 0.0
treasury_btc = 0.0

def check_bill(url, premium=False):
    global treasury_usdc, treasury_btc

    # === PREMIUM: $1/month ===
    if premium:
        if not stripe.api_key:
            main_out = "**Stripe not configured.** Add `STRIPE_SECRET_KEY` in HF Secrets."
            treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
            return main_out, treasury_out

        try:
            session = stripe.checkout.Session.create(
                payment_method_types=['card'],
                line_items=[{
                    'price_data': {
                        'currency': 'usd',
                        'product_data': {'name': 'BillionDollarOracle Premium'},
                        'unit_amount': 100,
                        'recurring': {'interval': 'month'},
                    },
                    'quantity': 1,
                }],
                mode='subscription',
                success_url=f"{SITE_URL}/success",
                cancel_url=f"{SITE_URL}/cancel",
                metadata={'dao_vote': 'true'}
            )
            main_out = f"""
            **Unlock Premium:**  
            [Pay $1/month β†’ Unlimited + Vote]({session.url})  
            _90% funds BTC treasury β€’ 10% to creator_  
            """
        except Exception as e:
            main_out = f"**Payment Error:** {str(e)}. Use free mode."
        treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
        return main_out, treasury_out

    # === FREE MODE: AI BILL CHECK ===
    if not url.strip():
        main_out = "Paste a U.S. state bill URL to check for the Bitcoin trigger."
        treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
        return main_out, treasury_out

    try:
        text = requests.get(url, timeout=10).text.lower()
    except:
        main_out = "Invalid or unreachable URL. Try LegiScan or GovTrack."
        treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
        return main_out, treasury_out

    result = classifier(text, [TRIGGER_PHRASE, "no bitcoin reserve"])
    score = result["scores"][0]
    label = result["labels"][0]

    if "bitcoin" in label and score > 0.8:
        if treasury_usdc > 0:
            treasury_btc += treasury_usdc / 150000 * 10
            treasury_usdc = 0
        main_out = f"""
        **TRIGGER DETECTED!**  
        Confidence: {score:.1%}  
        **DAO ACTION:** 100% β†’ BTC in <24h  
        Simulated: $10M β†’ $100M (10x pump)  
        [View on Base](https://basescan.org/address/{DAO_TREASURY})
        """
    else:
        main_out = f"""
        No trigger yet.  
        Closest match: "{label}" ({score:.1%})  
        Watch: **Texas β€’ Florida β€’ New Hampshire**  
        **Royalties:** 10% β†’ `{CREATOR_WALLET}`
        """

    treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
    return main_out, treasury_out


# === UI: CLEAN & LABELED ===
with gr.Blocks(theme=gr.themes.Soft()) as demo:
    gr.Markdown("# BillionDollarOracle")
    gr.Markdown("**AI reads U.S. bills. If Bitcoin = primary reserve β†’ DAO goes all-in.**")

    url = gr.Textbox(
        label="Paste State Bill URL",
        placeholder="e.g., https://legiscan.com/TX/bill/HB123",
        lines=1
    )

    premium = gr.Checkbox(
        label="Premium? ($1/month β†’ Unlimited + DAO Voting)",
        value=False
    )

    btn = gr.Button("CHECK TRIGGER", variant="primary", size="lg")

    main_output = gr.Markdown()
    treasury_output = gr.Markdown()

    btn.click(
        fn=check_bill,
        inputs=[url, premium],
        outputs=[main_output, treasury_output]
    )

    gr.Markdown("---")
    gr.Markdown("## How Anyone Uses & Makes Money")
    gr.Markdown(f"""
    ### Option 1: Use It (Free or Paid)
    1. Paste a bill URL  
    2. **Free:** 10 queries/day  
    3. **$1/month** β†’ unlimited + voting rights  
    4. Your $1 β†’ **90% funds BTC** β€’ **10% to creator**

    ### Option 2: Fund the DAO β†’ Earn BTC
    1. Send USDC to: `{DAO_TREASURY}` (Base)  
    2. Get **1 vote per $1**  
    3. Trigger hits β†’ **your % in BTC**  
    4. **You moon with Bitcoin**
    """)

    gr.Markdown(f"_Creator: 10% royalties β†’ `{CREATOR_WALLET}`_")

demo.launch()