InnerI commited on
Commit
6672210
Β·
verified Β·
1 Parent(s): 67d7025

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -45
app.py CHANGED
@@ -5,9 +5,9 @@ from transformers import pipeline
5
  import stripe
6
  import os
7
 
8
- # === CONFIG (Add to HF Secrets!) ===
9
  stripe.api_key = os.getenv("STRIPE_SECRET_KEY")
10
- CREATOR_WALLET = os.getenv("YOUR_WALLET", "0xYourBaseWalletHere")
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 = "**Error: Stripe key missing.** Add `STRIPE_SECRET_KEY` in HF Secrets."
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( # Note: 'create' not 'checkout.sessions.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, # $1.00
37
  'recurring': {'interval': 'month'},
38
  },
39
  'quantity': 1,
40
  }],
41
  mode='subscription',
42
- success_url=f"{SITE_URL}/success?session_id={{CHECKOUT_SESSION_ID}}",
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 Unlock:**
49
- Redirecting to Stripe... (if no popup, click below)
50
  [Pay $1/month β†’ Unlimited + Vote]({session.url})
51
- 90% β†’ BTC treasury | 10% β†’ `{CREATOR_WALLET}`
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"**Unexpected Error:** {str(e)}. Use free mode."
57
- else:
58
- main_out = main_out # From try block
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. Use LegiScan, GovTrack, or state site."
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 # 10x pump
77
  treasury_usdc = 0
78
  main_out = f"""
79
- **TRIGGER HIT!**
80
  Confidence: {score:.1%}
81
- **DAO β†’ 100% BTC**
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: TX, FL, NH, AZ bills.
90
- **10% Royalties β†’** `{CREATOR_WALLET}`
91
  """
92
 
93
  treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
94
- return main_out, treasury_out # ← FIXED: 2 outputs
95
 
96
 
97
- # === UI ===
98
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
99
  gr.Markdown("# BillionDollarOracle")
100
- gr.Markdown("AI scans bills. Bitcoin = primary reserve? β†’ DAO goes all-in.")
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- url = gr.Textbox(label="Paste Bill URL", placeholder="https://legiscan.com/TX/bill/HB123")
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, key],
115
- outputs=[main_output, treasury_output] # ← 2 outputs
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: 10 queries/day
124
- 3. **$1/month** β†’ unlimited + vote
125
- 4. 90% funds BTC β†’ **10% to creator**
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
- demo.launch(share=True)
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()