verify / app.py
Accelernate's picture
Update app.py
f26b47f verified
import streamlit as st
import requests
st.title("Verify πŸ‘»")
# Fixed Token Mint Addresses (hidden from user)
TOKEN_MINT_ADDRESSES = {
"$TRICK": "EAXn2aA4GRE4p7r5q77NynHnQhaWnU5Pw66GSWQ4pump", # TRICK token mint address
"$TREAT": "3JqD4oUp1YzvzGWF2WJjrELr4QkW1GDLyFdtYnukpump" # TREAT token mint address
}
# Input field for the wallet address
wallet_address = st.text_input("Enter your Solana wallet address:")
if st.button("Verify"):
if wallet_address:
try:
# Solana RPC endpoint
rpc_endpoint = "https://api.mainnet-beta.solana.com"
total_adjusted_amount = 0
# Loop through token types (TRICK and TREAT)
for token_name, token_mint_address in TOKEN_MINT_ADDRESSES.items():
# Prepare the request payload
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByOwner",
"params": [
wallet_address,
{"mint": token_mint_address},
{"encoding": "jsonParsed"}
]
}
# Send the request
response = requests.post(rpc_endpoint, json=payload)
result = response.json()
# Check if any token accounts were found
if (
'result' in result and
'value' in result['result'] and
len(result['result']['value']) > 0
):
# Get the balance (assuming only one account for simplicity)
token_account = result['result']['value'][0]
balance_info = token_account['account']['data']['parsed']['info']['tokenAmount']
amount = int(balance_info['amount']) # amount in the smallest unit
# Adjust for token decimals
decimals = balance_info['decimals']
adjusted_amount = amount / (10 ** decimals)
# Add to total amount
total_adjusted_amount += adjusted_amount
# Display the amount the user holds for each token (TRICK or TREAT)
st.write(f"You hold {adjusted_amount:,.0f} {token_name} tokens.")
else:
st.write(f"No {token_name} tokens found.")
# Compare the total adjusted amount to thresholds
if total_adjusted_amount >= 333333:
st.success("βœ… Guaranteed OG Status")
elif total_adjusted_amount >= 33333:
st.success("βœ… Guaranteed Trencher Status")
elif total_adjusted_amount >= 3333:
st.success("βœ… Guaranteed Raider Status")
else:
st.error("You don't have enough tokens yet πŸ‘»")
# Log the query to Google Form
try:
form_url = "https://docs.google.com/forms/d/e/1FAIpQLSfsLawJnLd14ZGd8-fsbTdqGSsCSESe1w8Zd39wigDn6pvokQ/formResponse"
form_data = {
'entry.1721628210': wallet_address, # Replace with your actual Wallet Address field name
'entry.1357327531': f"{total_adjusted_amount:,.0f}" # Replace with your actual Token Amount field name
}
response = requests.post(form_url, data=form_data)
if response.status_code != 200:
st.warning("Failed to log data to Google Form.")
except Exception as e:
st.warning(f"Failed to log data to Google Form: {e}")
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.warning("Please enter your wallet address.")