I’m making a simple script to perform a swap in Jupiter. After defining the public/private keys and the parameters for the transaction, doing the request to the api and validating the last blockhash Im trying to set up the transaction this way :
#Comprobomas cual es el hash del ultimo bloque ,esto es necesario para crear una stransaccion firmanda
latest_blockhash = client.get_latest_blockhash()
blockhash = latest_blockhash.value.blockhash
print(f'{blockhash}')
# Obtener los componentes de la transacción original
original_message = versioned_transaction.message
# Crear un nuevo MessageV0 con el recent_blockhash actualizado
new_message = MessageV0.try_compile(
payer=original_message.account_keys[0], # Supongamos que el pagador es la primera cuenta
instructions=original_message.instructions,
address_lookup_table_accounts=[],
recent_blockhash=(blockhash)
)
# Crear una nueva transacción con el mensaje actualizado
new_transaction = VersionedTransaction(new_message, versioned_transaction.signatures)
# Imprimir el ID de la transacción
print(f'Transacción enviada ID: {txid}')
I tried to use populate function and Transaction.sign in multiple ways but I think I’m not doing it correctly. I know it is probably a really simple solution but I’m learning coding just for few weeks (I’m on week7 from cs50). Any help will be really appreciated.
Thx.
Pablo Llamazares is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.