OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Problems to sign a simple swap in solana , using jupiter api and python

  • Thread starter Thread starter Pablo Llamazares
  • Start date Start date
P

Pablo Llamazares

Guest
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 :

Code:
#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.
<p>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 :</p>
<pre><code>#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}')
</code></pre>
<p>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.</p>
 

Latest posts

Top