[Python] why do i keep getting this ERROR - ❌ Transaction signing failed:...

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    i keep getting this error here is the part of the script what am i doing wrong? i can not get the to fully complete the transaction i am using this for a buy/sell volume bot

    try: # ✅ Decode transaction bytes transaction_bytes = base64.b64decode(tx_data["swapTransaction"]) transaction = VersionedTransaction.from_bytes(transaction_bytes) # Ensure 'transaction' is properly defined

    # ✅ Correct method to sign the transaction
    transaction.sign([keypair])

    # ✅ Serialize the signed transaction
    signed_transaction_bytes = transaction.serialize()

    # ✅ Send the signed transaction
    response = sol_client.send_transaction(transaction, keypair)
    txid = response.get("result", None)

    if txid:
    logging.info(f"✅ Trade executed successfully! TXID: {txid}")
    return txid
    else:
    logging.warning(f"⚠️ Transaction may have failed: {response}")

    except Exception as e:
    logging.error(f"❌ Transaction signing failed: {str(e)}")
    return None


    ive tried this version to and get get hung up at the same place in the signing of the transaction

    try: # ✅ Decode transaction bytes transaction_bytes = base64.b64decode(tx_data["swapTransaction"]) transaction = VersionedTransaction.from_bytes(transaction_bytes)

    # ✅ FIX: Manually sign the transaction
    message_bytes = bytes(transaction.message)
    signature = keypair.sign_message(message_bytes)

    # ✅ Attach the signature manually
    transaction.signatures[0] = signature

    # ✅ Send the signed transaction to Solana
    txid = sol_client.send_transaction(transaction, keypair)

    if txid:
    logging.info(f"✅ {trade_type.capitalize()} executed successfully! TXID: {txid}")
    return txid
    else:
    logging.warning(f"⚠️ Transaction {trade_type} may have failed: {txid}")

    except Exception as e:
    logging.error(f"❌ Transaction signing failed: {str(e)}")
    return None

    Continue reading...

Compartilhe esta Página