Accelernate commited on
Commit
c896c68
·
verified ·
1 Parent(s): 7258863

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -48
app.py CHANGED
@@ -1,51 +1,59 @@
1
- from solana.rpc.async_api import AsyncClient
2
- from solana.publickey import PublicKey
3
- import asyncio
4
  import requests
5
 
6
- # The token's mint address for the desired token you want to verify
7
- token_mint_address = "YourTokenMintAddressHere"
8
-
9
- # Function to get all SPL token accounts for a given wallet
10
- async def get_token_accounts(wallet_address):
11
- async with AsyncClient("https://api.mainnet-beta.solana.com") as client:
12
- response = await client.get_token_accounts_by_owner(PublicKey(wallet_address),
13
- program_id=PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"))
14
- return response['result']['value']
15
-
16
- # Function to check if the wallet holds a specific token and amount
17
- def verify_token_holding(token_accounts, token_mint_address, required_amount):
18
- for account in token_accounts:
19
- account_data = account['account']['data']['parsed']['info']
20
- if account_data['mint'] == token_mint_address:
21
- amount = float(account_data['tokenAmount']['uiAmount'])
22
- if amount >= required_amount:
23
- return True, amount
24
- return False, 0
25
-
26
- # Main function
27
- async def check_wallet(wallet_address, token_mint_address, required_amount):
28
- token_accounts = await get_token_accounts(wallet_address)
29
- is_holding, amount = verify_token_holding(token_accounts, token_mint_address, required_amount)
30
- if is_holding:
31
- print(f"The wallet {wallet_address} holds at least {required_amount} of the token {token_mint_address}. It holds: {amount}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  else:
33
- print(f"The wallet {wallet_address} does not hold the required amount of the token.")
34
-
35
- # Prompt the user to enter their wallet address
36
- wallet_address = input("Please enter your wallet address: ")
37
- required_amount = float(input("Please enter the required amount: "))
38
-
39
- # Run the check
40
- token_mint_address = "ReplaceWithYourTokenMintAddress"
41
- asyncio.run(check_wallet(wallet_address, token_mint_address, required_amount))
42
-
43
- # Install required dependencies:
44
- # pip install solana requests
45
-
46
- """
47
- This script is designed to check if a given Solana wallet holds a certain token and the required amount.
48
- To use this script:
49
- 1. Replace "ReplaceWithYourTokenMintAddress" with the actual token mint address.
50
- 2. The script will prompt the user to paste their wallet address and required token amount.
51
- """
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
  import requests
5
 
6
+ st.title("Solana Wallet Verifier")
7
+
8
+ # Input fields for the wallet address and token mint address
9
+ wallet_address = st.text_input("Enter your Solana wallet address:")
10
+ token_mint_address = st.text_input("Enter the token mint address:")
11
+
12
+ if st.button("Verify"):
13
+ if wallet_address and token_mint_address:
14
+ try:
15
+ # Solana RPC endpoint
16
+ rpc_endpoint = "https://api.mainnet-beta.solana.com"
17
+
18
+ # Prepare the request payload
19
+ payload = {
20
+ "jsonrpc": "2.0",
21
+ "id": 1,
22
+ "method": "getTokenAccountsByOwner",
23
+ "params": [
24
+ wallet_address,
25
+ {"mint": token_mint_address},
26
+ {"encoding": "jsonParsed"}
27
+ ]
28
+ }
29
+
30
+ # Send the request
31
+ response = requests.post(rpc_endpoint, json=payload)
32
+ result = response.json()
33
+
34
+ # Check if any token accounts were found
35
+ if 'result' in result and 'value' in result['result'] and len(result['result']['value']) > 0:
36
+ # Get the balance (assuming only one account for simplicity)
37
+ token_account = result['result']['value'][0]
38
+ balance_info = token_account['account']['data']['parsed']['info']['tokenAmount']
39
+ amount = int(balance_info['amount']) # amount in the smallest unit
40
+
41
+ # Adjust for token decimals
42
+ decimals = balance_info['decimals']
43
+ adjusted_amount = amount / (10 ** decimals)
44
+
45
+ # Compare the adjusted amount to thresholds
46
+ if adjusted_amount >= 3333333:
47
+ st.success("✅ Guaranteed OG Status")
48
+ elif adjusted_amount >= 333333:
49
+ st.success("✅ Guaranteed WLT Status")
50
+ elif adjusted_amount >= 33333:
51
+ st.success("✅ Guaranteed WLR Status")
52
+ else:
53
+ st.error("You do not meet any status requirements.")
54
+ else:
55
+ st.error("Token account not found or zero balance.")
56
+ except Exception as e:
57
+ st.error(f"An error occurred: {e}")
58
  else:
59
+ st.warning("Please enter both wallet address and token mint address.")