xyizko commited on
Commit
c035890
·
verified ·
1 Parent(s): 55fcb5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -14
app.py CHANGED
@@ -60,9 +60,27 @@ def check_flagged_address(address: str, hf_token: str):
60
 
61
  # Format the response
62
  if flagged:
63
- return f"Address {address} is Flagged ✅\nChain: {chain}\nStatus: Present in Bybit hack database"
64
  else:
65
- return f"Address {address} is Not Flagged ❌\nChain: {chain}\nStatus: Not present in Bybit hack database"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  # Gradio chat function
68
  def chat_with_agent(user_input, chat_history, hf_token):
@@ -81,8 +99,8 @@ def chat_with_agent(user_input, chat_history, hf_token):
81
  chat_history.append({"role": "assistant", "content": "Please enter a valid Hugging Face API token."})
82
  return chat_history, ""
83
 
84
- # Run the address checker
85
- response = check_flagged_address(user_input, hf_token)
86
 
87
  # Append as OpenAI-style messages
88
  chat_history.append({"role": "user", "content": user_input})
@@ -92,13 +110,13 @@ def chat_with_agent(user_input, chat_history, hf_token):
92
  return chat_history, ""
93
 
94
  # Create the Gradio interface with tabs
95
- with gr.Blocks(title="Bybit Hack Address Checker") as demo:
96
- gr.Markdown("# Bybit Hack Address Checker")
97
 
98
  with gr.Tabs():
99
  # Tab 1: Address Checker UI
100
  with gr.Tab(label="Check Address"):
101
- gr.Markdown("Enter a cryptocurrency address to check if it's flagged in the Bybit hack database and identify its blockchain.")
102
  gr.Markdown("Provide your Hugging Face API token below (get it from [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)).")
103
 
104
  # HF Token input
@@ -114,7 +132,7 @@ with gr.Blocks(title="Bybit Hack Address Checker") as demo:
114
 
115
  # Address input
116
  msg = gr.Textbox(
117
- placeholder="Enter address here (e.g., 0x123..., bc1q...)",
118
  label="Address",
119
  lines=1
120
  )
@@ -142,18 +160,18 @@ with gr.Blocks(title="Bybit Hack Address Checker") as demo:
142
  ## What This App Does
143
  This application helps you verify if a cryptocurrency address is associated with the Bybit hack, as tracked by the Elliptic dataset. Here’s how it works:
144
 
145
- 1. **Input an Address**: Enter a wallet address (e.g., Ethereum `0x...`, Bitcoin `bc1q...`, Tron `T...`) in the 'Check Address' tab.
146
  2. **Provide HF Token**: Supply a Hugging Face API token to access the AI model powering the agent.
147
- 3. **Agent Processing**: The app uses a **language model** to infer the blockchain of the address (Ethereum, Bitcoin, Tron, etc.).
148
- 4. **Flag Check**: It then checks the address against a list of flagged addresses from the Elliptic Bybit hack dataset (`https://dt074px2e9qbh.cloudfront.net/exploit-api.json`).
149
- 5. **Result**: You’ll see whether the address is flagged ✅ or not ❌, its chain type, and if it’s present in the database.
150
 
151
  ### Why It’s Useful
152
- - **Security**: Quickly check if an address youre dealing with is linked to a known exploit.
153
  - **Free & Open**: Uses free-tier AI and public data, making it accessible to anyone with an HF account.
154
  - **Educational**: Demonstrates AI-driven blockchain analysis with a large language model.
155
 
156
- Get started by entering your HF token and an address in the 'Check Address' tab!
157
  """)
158
 
159
  # Launch the app
 
60
 
61
  # Format the response
62
  if flagged:
63
+ return f"Address {address} is Flagged ✅\nChain: {chain}\nStatus: Present in Bybit Blocked List"
64
  else:
65
+ return f"Address {address} is Not Flagged ❌\nChain: {chain}\nStatus: Not present in Bybit Blocked List"
66
+
67
+ # Function to handle multiple addresses input
68
+ def handle_multiple_addresses(user_input, hf_token):
69
+ """Process multiple addresses separated by commas."""
70
+ results = []
71
+
72
+ # Split input into multiple addresses
73
+ addresses = [addr.strip() for addr in user_input.split(",")]
74
+
75
+ # Process each address individually
76
+ for address in addresses:
77
+ if address: # Skip empty inputs
78
+ result = check_flagged_address(address, hf_token)
79
+ results.append(result)
80
+ else:
81
+ results.append("Empty address entered, please try again.")
82
+
83
+ return "\n\n".join(results) # Combine results with two newlines
84
 
85
  # Gradio chat function
86
  def chat_with_agent(user_input, chat_history, hf_token):
 
99
  chat_history.append({"role": "assistant", "content": "Please enter a valid Hugging Face API token."})
100
  return chat_history, ""
101
 
102
+ # Handle multiple addresses
103
+ response = handle_multiple_addresses(user_input, hf_token)
104
 
105
  # Append as OpenAI-style messages
106
  chat_history.append({"role": "user", "content": user_input})
 
110
  return chat_history, ""
111
 
112
  # Create the Gradio interface with tabs
113
+ with gr.Blocks(title="Bybit Blocked Address Check") as demo:
114
+ gr.Markdown("# Bybit Blocked Address Check")
115
 
116
  with gr.Tabs():
117
  # Tab 1: Address Checker UI
118
  with gr.Tab(label="Check Address"):
119
+ gr.Markdown("Enter one or more cryptocurrency addresses (separated by commas) to check if they're flagged in the Bybit hack database.")
120
  gr.Markdown("Provide your Hugging Face API token below (get it from [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)).")
121
 
122
  # HF Token input
 
132
 
133
  # Address input
134
  msg = gr.Textbox(
135
+ placeholder="Enter address(es) here (separated by commas)",
136
  label="Address",
137
  lines=1
138
  )
 
160
  ## What This App Does
161
  This application helps you verify if a cryptocurrency address is associated with the Bybit hack, as tracked by the Elliptic dataset. Here’s how it works:
162
 
163
+ 1. **Input one or more Addresses**: Enter one or more wallet addresses (separated by commas).
164
  2. **Provide HF Token**: Supply a Hugging Face API token to access the AI model powering the agent.
165
+ 3. **Agent Processing**: The app uses a **language model** to infer the blockchain of each address (Ethereum, Bitcoin, Tron, etc.).
166
+ 4. **Flag Check**: It then checks each address against a list of flagged addresses from the Elliptic Bybit hack dataset (`https://dt074px2e9qbh.cloudfront.net/exploit-api.json`).
167
+ 5. **Result**: You’ll see whether each address is flagged ✅ or not ❌, its chain type, and if it’s present in the database.
168
 
169
  ### Why It’s Useful
170
+ - **Security**: Quickly check if any address you're dealing with is linked to a known exploit.
171
  - **Free & Open**: Uses free-tier AI and public data, making it accessible to anyone with an HF account.
172
  - **Educational**: Demonstrates AI-driven blockchain analysis with a large language model.
173
 
174
+ Get started by entering your HF token and addresses in the 'Check Address' tab!
175
  """)
176
 
177
  # Launch the app