Solana: Programmable swap on Jupiter

Solana: Programmable Swap on Jupiter – A Common Issue

As Solana’s programmability continues to grow, so do the complexities of swapping assets. One common issue that arises is when a user submits a “Jupiter swap” transaction but it gets flagged as “Transaction not found” on Solscan.

In this article, we’ll delve into the reasons behind this issue and explore potential solutions to solve it.

What is a Jupiter swap?

A Jupiter swap is a type of asset exchange that allows users to swap one asset for another, using a liquidity pool. This is achieved through a series of steps:

  • A user submits an “Initial Token” (IT) proposal on the Solana blockchain.

  • The proposal is reviewed by a validator and approved if it meets certain conditions.

  • Once approved, the IT token is used to create a liquidity pool on the Solana chain.

The liquidity pool acts as a marketplace, where users can deposit their assets (e.g., USDT) and receive another asset in exchange. This allows for low-cost trading and efficient asset swaps.

Why is it flagged as “Transaction not found” on Solscan?

When a user submits an Initial Token proposal, the Solana blockchain creates a “Jupiter swap transaction”. However, this transaction is not visible on Solscan due to its internal design. The reason lies in how the transaction is stored and queried.

The issue:

  • Transaction ID: When a user submits an Initial Token proposal, a unique Transaction ID (txID) is generated.

  • Tx Hash

    : This txHash value is used as the “transaction” for Solscan’s query.

  • Query: The Solana blockchain uses the txHash to retrieve relevant information about the transaction.

However, if the transaction ID is not properly encoded or referenced in Solscan, it returns an error message saying “Transaction not found”.

Potential solutions:

  • Use a unique identifier: Instead of relying on the txHash, consider using a unique identifier for your Jupiter swap transactions. You can create a uint256 variable to store this ID and pass it as a parameter in your code.

  • Store the transaction ID separately: If you need to reference the txID later, consider storing it separately from the txHash. This way, when querying Solscan, you can provide both values ​​and retrieve relevant information.

  • Use Solana’s built-in address data type: Instead of using a string or another value as an address in your code, leverage Solana’s native address data type. This allows for more efficient storage and querying.

Example Code:

Here’s a simple example that demonstrates the first solution:

import solscan

def generate_jupiter_swap_id(it_id):


Generate a unique identifier using the itId parameter

swap_id = it_id.to_string()

return swap_id


Assume we have an InitialToken proposal with an IT ID of 1234567890abcdef

it_id = solscan.Address.from_string("1234567890abcdef")

swap_id = generate_jupiter_swap_id(it_id)

print(swap_id)

Output: 1234567890abcdef (the unique identifier)


Now, when querying Solscan:

jupiter_swap_tx_hash = solscan.get_jupiter_swap_transaction_hash(

it_id.to_string(), swap_id

)

print(jupyter_swap_tx_hash)

In this example, we generate a unique swapId by concatenating the itId parameter. When querying Solscan for the Jupiter swap transaction hash, you can provide both the txHash and the swapId, which allows Solscan to correctly retrieve relevant information.

Bottom line:

While the “Transaction not found” error on Solscan is frustrating, it’s essential to understand why this occurs. By exploring potential solutions and using the correct data types, you should be able to resolve this issue and successfully execute your Jupiter swap transactions.

Leave a Reply

Your email address will not be published. Required fields are marked *