#!/bin/bash
# Query ALL Mainnet for token information
# This script attempts to query common token addresses on ALL Mainnet

RPC_URL="https://mainnet-rpc.alltra.global"
CHAIN_ID=651940

echo "🔍 Querying ALL Mainnet (ChainID $CHAIN_ID) for token information..."
echo "RPC: $RPC_URL"
echo ""

# Check if cast is available
if ! command -v cast &> /dev/null; then
    echo "⚠️  cast (foundry) not available. Install foundry to use this script."
    echo "   Or use ethers.js/node script instead."
    exit 1
fi

# Test RPC connection
echo "Testing RPC connection..."
BLOCK_NUM=$(cast block-number --rpc-url "$RPC_URL" 2>/dev/null)
if [ $? -eq 0 ]; then
    echo "✅ RPC accessible (block: $BLOCK_NUM)"
else
    echo "❌ RPC not accessible. Cannot query tokens."
    exit 1
fi

echo ""
echo "📋 Common token addresses to check:"
echo ""
echo "Note: These are common addresses on other chains. Actual addresses on ALL Mainnet may differ."
echo ""
echo "To find actual tokens:"
echo "1. Visit https://alltra.global/tokens"
echo "2. Check token contract addresses"
echo "3. Query each address for symbol, name, decimals"
echo ""
echo "Example query (replace ADDRESS with actual token address):"
echo "  cast call <ADDRESS> 'symbol()(string)' --rpc-url $RPC_URL"
echo "  cast call <ADDRESS> 'name()(string)' --rpc-url $RPC_URL"
echo "  cast call <ADDRESS> 'decimals()(uint8)' --rpc-url $RPC_URL"
