Skip to content

Persistent TypeError: 'str' object cannot be interpreted as an integer in Pubkey conversion (macOS/Windows, Docker) #569

@AndreaDallago

Description

@AndreaDallago

Problem Description:

I'm encountering a persistent TypeError: str object cannot be interpreted as an integer when using solders.pubkey.Pubkey.from_string (or Pubkey.from_bytes after base58.b58decode fallback) to convert Base58 public key strings to Pubkey objects. This happens consistently for every single transaction I attempt to parse from Solana's jsonParsed RPC output, causing the bot to repeatedly skip transactions.

The error occurs at a low level within solders's internal routines for interpreting pubkey_bytes.

Environment Details:

  • Operating System (primary): macOS Sequoia 15.5]
  • CPU Architecture (macOS): Apple M3 Pro
  • Operating System (tested secondary): Windows 11 x64 (tested on a different machine with Docker, same error observed)
  • Python Version (inside Docker container): Python 3.10.12 (base image python:3.10-slim-buster)
  • solana-py version: solana==0.30.0
  • solders version: solders==0.15.0
  • Other relevant libraries: websockets, python-dotenv, base58 (installed for fallback)
  • RPC/WS Provider: Tested with both Helius and QuickNode (same error observed with both).

Steps to Reproduce:

  1. Set up a Python environment (either local venv or Docker).
  2. Install solana==0.30.0, solders==0.15.0, websockets, python-dotenv, base58.
  3. Connect to a Solana Mainnet RPC/WS endpoint (e.g., Helius, QuickNode).
  4. Subscribe to transaction logs (e.g., logsSubscribe for all).
  5. For each received transaction signature, fetch full transaction details (get_transaction(signature, 'jsonParsed')).
  6. Attempt to parse source and destination fields from compiled_instruction.parsed.info (for native SOL transfers) into Pubkey objects using Pubkey.from_string().

Code Snippet (simplified relevant part where the error is caught):

from solders.pubkey import Pubkey
import base58 # Assuming installed

# 'from_wallet_str' and 'to_wallet_str' are strings obtained from RPC 'jsonParsed' output
# e.g., from_wallet_str = "D1WfNqfPdy24tL3ZfW2u929jV937y373Y37J7B373Y3" (example valid Base58 pubkey)

try:
    from_pubkey = Pubkey.from_string(from_wallet_str)
    to_pubkey = Pubkey.from_string(to_wallet_str)
except Exception as e_direct:
    try:
        # Debug prints confirmed type <class 'str'>
        # print(f"DEBUG: FROM_VALUE: '{from_wallet_str}' (Type: {type(from_wallet_str)})")
        
        from_bytes = base58.b58decode(from_wallet_str)
        to_bytes = base58.b58decode(to_wallet_str)
        
        from_pubkey = Pubkey.from_bytes(from_bytes)
        to_pubkey = Pubkey.from_bytes(to_bytes)

    except Exception as e_manual:
        # This is the point where the primary error message is generated.
        print(f"Errore nel recuperare o processare i dettagli della transazione [signature]: argument 'pubkey_bytes': 'str' object cannot be interpreted as an integer")
        # The bot continues execution after printing this message, skipping the transaction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    soldersIssue that should be transferred to https://github.com/kevinheavey/solders/issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions