Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7925

Error: expected a sequence of length 32 (got 44)

$
0
0

I am a python newbie and I am trying to create a simple wallet balance tracker for solana, I keep getting the error message: Error: expected a sequence of length 32 (got 44)heres the code:

import solanafrom solana.rpc.api import Clientfrom solders.pubkey import Pubkey# Initialize the Solana clientsolana_client = Client("https://api.mainnet-beta.solana.com")def get_wallet_balance(wallet_address):    try:        # Convert the wallet address to a PublicKey object        wallet_pubkey = Pubkey(wallet_address)        # Get the balance of the wallet        balance_info = solana_client.get_balance(wallet_pubkey)        # Extract the balance in lamports        balance_lamports = balance_info['result']['value']        # Convert lamports to SOL (1 SOL = 10^9 lamports)        balance_sol = balance_lamports / 1e9        return f"The balance of wallet {wallet_address} is {balance_sol} SOL."    except Exception as e:        return f"Error: {e}"def main():    print("Welcome to the Solana Wallet Tracker!")    while True:        # Ask the user for a wallet address        wallet_address = input("Enter a Solana wallet address (e.g., '9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin') or 'q' to quit: ")        if wallet_address.lower() == 'q':            print("Exiting the Solana Wallet Tracker. Goodbye!")            break        # Get and print the balance of the specified wallet        result = get_wallet_balance(wallet_address)        print(result)        print()if __name__ == "__main__":    main()

Viewing all articles
Browse latest Browse all 7925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>