Title:
Solana: Exchange API – Balance change is not shown when the Jupiter exchange API is used
Introduction
When working with the Solana block chain using the Jupiter exchange API, users have faced a frustrating problem in which their wallet balances do not precisely reflect the changes after exchange tokens. In this article, we will deepen the details of the problem and provide a solution to show the equilibrium changes in the wallet.
The problem
The main concern here is that when creating a transaction to exchange tokens using Jupiter’s API, the balance
field in the transaction chain is not updated with the new balance after the exchange. This can lead to confusion among users that may not be aware of their current balance before and after exchange.
For example, suppose you are trying to exchange 100 sun for 50 sun using Jupiter’s API. Initially, your wallet has 100 sun. After exchanging, he hopes his new balance is 150 Sol. However, when signing the transaction, nothing seems to happen and its balance does not change.
The solution
To show correct equilibrium changes in your wallet, we need to update the balance
field in the transaction chain using the following code fragment:
`JSON
{
"Method": "exchange",
"Parameters": [
{
"From": "Your_account_address",
"To": "Jupiter_token_address", // swap token
"Quantity": "1000000", // initial amount to exchange (in Solana units)
"New_balance": "1500000" // New Balance after exchange (in Solana units)
}
]
}
This is what changed:
- We add the field 'New_balance, which represents the new balance after the exchange.
- The ‘quantity’ field is now updated to include the initial amount of sun that is being exchanged.
Example use case
To test this solution, you can use a tool like Quicknode ( or the API of a programming language to create a chain of transactions with the previous code. When the transaction signs using your wallet, you should see an updated balance shown in the wallet.
Conclusion
The API Jupiter Swap provides a convenient way to exchange tokens in the Solana block chain. However, by showing equilibrium changes after exchange, users may not be aware of their current balances before and after the exchange. When updating the ‘Balance’ field with the New Balance after exchange, users can accurately track their Token balances and make informed decisions about their investments.
When implementing this solution, wallet suppliers can improve user experience by providing more precise information on changes in the balance, which is essential to administer Solana accounts effectively.