Spaces:
Sleeping
Sleeping
| # 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() |