Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,9 +5,9 @@ from transformers import pipeline
|
|
| 5 |
import stripe
|
| 6 |
import os
|
| 7 |
|
| 8 |
-
# === CONFIG (
|
| 9 |
stripe.api_key = os.getenv("STRIPE_SECRET_KEY")
|
| 10 |
-
CREATOR_WALLET = os.getenv("YOUR_WALLET", "
|
| 11 |
DAO_TREASURY = os.getenv("DAO_TREASURY", "0xB1LL10N...")
|
| 12 |
SITE_URL = os.getenv("SITE_URL", "https://billiondollaroracle.xyz")
|
| 13 |
TRIGGER_PHRASE = "bitcoin as the primary reserve asset"
|
|
@@ -20,50 +20,50 @@ treasury_btc = 0.0
|
|
| 20 |
def check_bill(url, premium=False):
|
| 21 |
global treasury_usdc, treasury_btc
|
| 22 |
|
|
|
|
| 23 |
if premium:
|
| 24 |
if not stripe.api_key:
|
| 25 |
-
main_out = "**
|
| 26 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 27 |
return main_out, treasury_out
|
| 28 |
|
| 29 |
try:
|
| 30 |
-
session = stripe.checkout.Session.create(
|
| 31 |
payment_method_types=['card'],
|
| 32 |
line_items=[{
|
| 33 |
'price_data': {
|
| 34 |
'currency': 'usd',
|
| 35 |
'product_data': {'name': 'BillionDollarOracle Premium'},
|
| 36 |
-
'unit_amount': 100,
|
| 37 |
'recurring': {'interval': 'month'},
|
| 38 |
},
|
| 39 |
'quantity': 1,
|
| 40 |
}],
|
| 41 |
mode='subscription',
|
| 42 |
-
success_url=f"{SITE_URL}/success
|
| 43 |
cancel_url=f"{SITE_URL}/cancel",
|
| 44 |
metadata={'dao_vote': 'true'}
|
| 45 |
)
|
| 46 |
-
# Force redirect in Gradio (popup/redirect)
|
| 47 |
main_out = f"""
|
| 48 |
-
**Premium
|
| 49 |
-
Redirecting to Stripe... (if no popup, click below)
|
| 50 |
[Pay $1/month β Unlimited + Vote]({session.url})
|
| 51 |
-
|
| 52 |
"""
|
| 53 |
-
except stripe.error.InvalidRequestError as e:
|
| 54 |
-
main_out = f"**Stripe Error:** {str(e)} (Check key/mode in dashboard)."
|
| 55 |
except Exception as e:
|
| 56 |
-
main_out = f"**
|
| 57 |
-
|
| 58 |
-
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 61 |
-
return main_out, treasury_out
|
| 62 |
|
| 63 |
try:
|
| 64 |
text = requests.get(url, timeout=10).text.lower()
|
| 65 |
except:
|
| 66 |
-
main_out = "Invalid URL.
|
| 67 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 68 |
return main_out, treasury_out
|
| 69 |
|
|
@@ -73,63 +73,70 @@ def check_bill(url, premium=False):
|
|
| 73 |
|
| 74 |
if "bitcoin" in label and score > 0.8:
|
| 75 |
if treasury_usdc > 0:
|
| 76 |
-
treasury_btc += treasury_usdc / 150000 * 10
|
| 77 |
treasury_usdc = 0
|
| 78 |
main_out = f"""
|
| 79 |
-
**TRIGGER
|
| 80 |
Confidence: {score:.1%}
|
| 81 |
-
**DAO
|
| 82 |
Simulated: $10M β $100M (10x pump)
|
| 83 |
[View on Base](https://basescan.org/address/{DAO_TREASURY})
|
| 84 |
"""
|
| 85 |
else:
|
| 86 |
main_out = f"""
|
| 87 |
-
No trigger.
|
| 88 |
-
Closest: "{label}" ({score:.1%})
|
| 89 |
-
Watch:
|
| 90 |
-
**10%
|
| 91 |
"""
|
| 92 |
|
| 93 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 94 |
-
return main_out, treasury_out
|
| 95 |
|
| 96 |
|
| 97 |
-
# === UI ===
|
| 98 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 99 |
gr.Markdown("# BillionDollarOracle")
|
| 100 |
-
gr.Markdown("AI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
-
premium = gr.Checkbox(label="Premium? ($1/mo β Unlimited + Vote)", value=False)
|
| 104 |
-
key = gr.Textbox(label="API Key", type="password", visible=False)
|
| 105 |
-
premium.change(lambda x: gr.update(visible=x), premium, key)
|
| 106 |
|
| 107 |
-
btn = gr.Button("CHECK TRIGGER", variant="primary")
|
| 108 |
-
|
| 109 |
main_output = gr.Markdown()
|
| 110 |
treasury_output = gr.Markdown()
|
| 111 |
|
| 112 |
btn.click(
|
| 113 |
fn=check_bill,
|
| 114 |
-
inputs=[url, premium
|
| 115 |
-
outputs=[main_output, treasury_output]
|
| 116 |
)
|
| 117 |
|
| 118 |
gr.Markdown("---")
|
| 119 |
gr.Markdown("## How Anyone Uses & Makes Money")
|
| 120 |
gr.Markdown(f"""
|
| 121 |
-
### Option 1: Use It
|
| 122 |
-
1. Paste bill URL
|
| 123 |
-
2. Free
|
| 124 |
-
3. **$1/month** β unlimited +
|
| 125 |
-
4. 90% funds BTC
|
| 126 |
-
|
| 127 |
-
### Option 2: Fund DAO
|
| 128 |
-
1. Send USDC to: `{DAO_TREASURY}`
|
| 129 |
2. Get **1 vote per $1**
|
| 130 |
3. Trigger hits β **your % in BTC**
|
| 131 |
4. **You moon with Bitcoin**
|
| 132 |
""")
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
| 5 |
import stripe
|
| 6 |
import os
|
| 7 |
|
| 8 |
+
# === CONFIG (HF Secrets) ===
|
| 9 |
stripe.api_key = os.getenv("STRIPE_SECRET_KEY")
|
| 10 |
+
CREATOR_WALLET = os.getenv("YOUR_WALLET", "0xYourWalletHere")
|
| 11 |
DAO_TREASURY = os.getenv("DAO_TREASURY", "0xB1LL10N...")
|
| 12 |
SITE_URL = os.getenv("SITE_URL", "https://billiondollaroracle.xyz")
|
| 13 |
TRIGGER_PHRASE = "bitcoin as the primary reserve asset"
|
|
|
|
| 20 |
def check_bill(url, premium=False):
|
| 21 |
global treasury_usdc, treasury_btc
|
| 22 |
|
| 23 |
+
# === PREMIUM: $1/month ===
|
| 24 |
if premium:
|
| 25 |
if not stripe.api_key:
|
| 26 |
+
main_out = "**Stripe not configured.** Add `STRIPE_SECRET_KEY` in HF Secrets."
|
| 27 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 28 |
return main_out, treasury_out
|
| 29 |
|
| 30 |
try:
|
| 31 |
+
session = stripe.checkout.Session.create(
|
| 32 |
payment_method_types=['card'],
|
| 33 |
line_items=[{
|
| 34 |
'price_data': {
|
| 35 |
'currency': 'usd',
|
| 36 |
'product_data': {'name': 'BillionDollarOracle Premium'},
|
| 37 |
+
'unit_amount': 100,
|
| 38 |
'recurring': {'interval': 'month'},
|
| 39 |
},
|
| 40 |
'quantity': 1,
|
| 41 |
}],
|
| 42 |
mode='subscription',
|
| 43 |
+
success_url=f"{SITE_URL}/success",
|
| 44 |
cancel_url=f"{SITE_URL}/cancel",
|
| 45 |
metadata={'dao_vote': 'true'}
|
| 46 |
)
|
|
|
|
| 47 |
main_out = f"""
|
| 48 |
+
**Unlock Premium:**
|
|
|
|
| 49 |
[Pay $1/month β Unlimited + Vote]({session.url})
|
| 50 |
+
_90% funds BTC treasury β’ 10% to creator_
|
| 51 |
"""
|
|
|
|
|
|
|
| 52 |
except Exception as e:
|
| 53 |
+
main_out = f"**Payment Error:** {str(e)}. Use free mode."
|
| 54 |
+
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 55 |
+
return main_out, treasury_out
|
| 56 |
|
| 57 |
+
# === FREE MODE: AI BILL CHECK ===
|
| 58 |
+
if not url.strip():
|
| 59 |
+
main_out = "Paste a U.S. state bill URL to check for the Bitcoin trigger."
|
| 60 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 61 |
+
return main_out, treasury_out
|
| 62 |
|
| 63 |
try:
|
| 64 |
text = requests.get(url, timeout=10).text.lower()
|
| 65 |
except:
|
| 66 |
+
main_out = "Invalid or unreachable URL. Try LegiScan or GovTrack."
|
| 67 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 68 |
return main_out, treasury_out
|
| 69 |
|
|
|
|
| 73 |
|
| 74 |
if "bitcoin" in label and score > 0.8:
|
| 75 |
if treasury_usdc > 0:
|
| 76 |
+
treasury_btc += treasury_usdc / 150000 * 10
|
| 77 |
treasury_usdc = 0
|
| 78 |
main_out = f"""
|
| 79 |
+
**TRIGGER DETECTED!**
|
| 80 |
Confidence: {score:.1%}
|
| 81 |
+
**DAO ACTION:** 100% β BTC in <24h
|
| 82 |
Simulated: $10M β $100M (10x pump)
|
| 83 |
[View on Base](https://basescan.org/address/{DAO_TREASURY})
|
| 84 |
"""
|
| 85 |
else:
|
| 86 |
main_out = f"""
|
| 87 |
+
No trigger yet.
|
| 88 |
+
Closest match: "{label}" ({score:.1%})
|
| 89 |
+
Watch: **Texas β’ Florida β’ New Hampshire**
|
| 90 |
+
**Royalties:** 10% β `{CREATOR_WALLET}`
|
| 91 |
"""
|
| 92 |
|
| 93 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 94 |
+
return main_out, treasury_out
|
| 95 |
|
| 96 |
|
| 97 |
+
# === UI: CLEAN & LABELED ===
|
| 98 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 99 |
gr.Markdown("# BillionDollarOracle")
|
| 100 |
+
gr.Markdown("**AI reads U.S. bills. If Bitcoin = primary reserve β DAO goes all-in.**")
|
| 101 |
+
|
| 102 |
+
url = gr.Textbox(
|
| 103 |
+
label="Paste State Bill URL",
|
| 104 |
+
placeholder="e.g., https://legiscan.com/TX/bill/HB123",
|
| 105 |
+
lines=1
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
premium = gr.Checkbox(
|
| 109 |
+
label="Premium? ($1/month β Unlimited + DAO Voting)",
|
| 110 |
+
value=False
|
| 111 |
+
)
|
| 112 |
|
| 113 |
+
btn = gr.Button("CHECK TRIGGER", variant="primary", size="lg")
|
|
|
|
|
|
|
|
|
|
| 114 |
|
|
|
|
|
|
|
| 115 |
main_output = gr.Markdown()
|
| 116 |
treasury_output = gr.Markdown()
|
| 117 |
|
| 118 |
btn.click(
|
| 119 |
fn=check_bill,
|
| 120 |
+
inputs=[url, premium],
|
| 121 |
+
outputs=[main_output, treasury_output]
|
| 122 |
)
|
| 123 |
|
| 124 |
gr.Markdown("---")
|
| 125 |
gr.Markdown("## How Anyone Uses & Makes Money")
|
| 126 |
gr.Markdown(f"""
|
| 127 |
+
### Option 1: Use It (Free or Paid)
|
| 128 |
+
1. Paste a bill URL
|
| 129 |
+
2. **Free:** 10 queries/day
|
| 130 |
+
3. **$1/month** β unlimited + voting rights
|
| 131 |
+
4. Your $1 β **90% funds BTC** β’ **10% to creator**
|
| 132 |
+
|
| 133 |
+
### Option 2: Fund the DAO β Earn BTC
|
| 134 |
+
1. Send USDC to: `{DAO_TREASURY}` (Base)
|
| 135 |
2. Get **1 vote per $1**
|
| 136 |
3. Trigger hits β **your % in BTC**
|
| 137 |
4. **You moon with Bitcoin**
|
| 138 |
""")
|
| 139 |
|
| 140 |
+
gr.Markdown(f"_Creator: 10% royalties β `{CREATOR_WALLET}`_")
|
| 141 |
+
|
| 142 |
+
demo.launch()
|