solana-py icon indicating copy to clipboard operation
solana-py copied to clipboard

libraries compatibility to python 3.12

Open majikdev24 opened this issue 1 year ago • 4 comments

some packages are not compatible with python 3.12

majikdev24 avatar Nov 21 '24 07:11 majikdev24

can you provide a more descriptive issue?

michaelhly avatar Nov 25 '24 16:11 michaelhly

Transaction Creation Error in solana-py v0.36.1

Environment & Versions

  • solana-py version: 0.36.1
  • Python version: 3.13
  • Dependencies: solders, construct-typing, httpx
  • Running on Solana devnet
  • Using QuickNode RPC endpoint

Issue Description

When attempting to create and send transfer transactions using the solders Transaction and Message classes, I'm consistently getting type conversion errors:

Error during distribution: argument 'payer': 'Hash' object cannot be converted to 'Pubkey'

Minimal Reproduction Code

from solana.rpc.api import Client
from solders.keypair import Keypair
from solders.transaction import Transaction
from solders.pubkey import Pubkey
from solders.message import Message
from solders.system_program import TransferParams, transfer
from solders.hash import Hash

# Setup
client = Client("https://api.devnet.solana.com")
sender_keypair = Keypair.from_bytes(bytes.fromhex(sender_private_key))
recipient_pubkey = Pubkey.from_string(recipient_address)

# Get blockhash
blockhash_resp = client.get_latest_blockhash()
recent_blockhash = blockhash_resp.value.blockhash

# Create transfer instruction
transfer_instruction = transfer(
    TransferParams(
        from_pubkey=sender_keypair.pubkey(),
        to_pubkey=recipient_pubkey,
        lamports=amount
    )
)

# This is where the error occurs
message = Message([transfer_instruction], recent_blockhash)
transaction = Transaction(
    from_keypairs=[sender_keypair],
    message=message
)

Expected Behavior

The transaction should be created successfully and ready to be sent.

Actual Behavior

Getting type conversion error suggesting the Message or Transaction constructor is expecting different types than what we're providing.

Questions

  1. What's the correct way to construct Message and Transaction objects in solana-py v0.36.1?
  2. Is there a specific constructor or method we should be using for transaction creation in this version?
  3. Could you provide an example of the correct transaction construction pattern?

Additional Context

  • The error specifically occurs when trying to distribute SOL to multiple wallets in a loop
  • Each individual parameter (pubkeys, instructions, blockhash) appears to be of the correct type when printed
  • We've tried various patterns of Message and Transaction construction without success

References

  • Based on examples from: https://github.com/michaelhly/solana-py
  • Using the solders package that comes with solana-py v0.36.1

musayub123 avatar Jan 04 '25 23:01 musayub123

Can you try again with the latest version?

michaelhly avatar Feb 08 '25 23:02 michaelhly

Has this issue been resolved? @musayub123

kingfavourjudah avatar Mar 06 '25 00:03 kingfavourjudah