velocity / components /checktoken.py
Junaidb's picture
Update components/checktoken.py
a3839ff verified
import httpx
async def TokenCheck(address):
url = "https://mainnet.helius-rpc.com/?api-key=4e833ada-d32c-48c5-b020-c11b2253f25b"
payload = {
"jsonrpc": "2.0",
"id": "1",
"method": "getTokenAccountsByOwner",
"params": [
address,
{"mint": "ENwLiycC5yWgWVTCYn6A4277HD5cFygxtxBuUuE3pump"},
{"encoding": "jsonParsed"}
],
}
try:
async with httpx.AsyncClient() as client:
response = await client.post(url, json=payload)
response.raise_for_status()
data = response.json()
except Exception:
return False
token_accounts = data.get("result", {}).get("value")
if not token_accounts:
return False
try:
account_info = token_accounts[0]["account"]["data"]["parsed"]["info"]
token_amount = account_info["tokenAmount"]
ui_amount = float(token_amount.get("uiAmount"))
except:
return False
return ui_amount >= 100000