solana-py
solana-py copied to clipboard
deserialize random behavior
input_mint = 'So11111111111111111111111111111111111111112' output_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' amount = 5000000000 slippage_bps = 50
api_url = f'https://quote-api.jup.ag/v6/quote?inputMint={input_mint}&outputMint={output_mint}&amount={amount}&slippageBps={slippage_bps}' quote_response = requests.get(api_url).json()
swap_transaction_response = requests.post('https://quote-api.jup.ag/v6/swap', json= { 'quoteResponse': quote_response, 'userPublicKey': str(public_key), 'wrapAndUnwrapSol': True, })
swap_transaction = swap_transaction_response.json()['swapTransaction'] tx = Transaction.deserialize(base64.b64decode(swap_transaction)) print(tx)
Randomly gives errors:
-
line 320, in deserialize return cls.from_solders(SoldersTx.from_bytes(raw_transaction)) ValueError: invalid value: continue signal on byte-three, expected a terminal signal on or before byte-three
-
line 320, in deserialize return cls.from_solders(SoldersTx.from_bytes(raw_transaction)) ValueError: invalid value: alias encoding, expected strict form encoding
-
line 320, in deserialize return cls.from_solders(SoldersTx.from_bytes(raw_transaction)) ValueError: io error: unexpected end of file
OR
Can randomly pass: <solana.transaction.Transaction object at 0x0000017316C11130>
(As it should)
can you check if the randomness is in solders or the API response?
can you check if the randomness is in solders or the API response?
The exact same error occurs to me as well, I believe the randomness of the errors are occuring in solders.
same here
Doesn't the Jup API give a VersionedTransaction instead of a legacy Transaction?
Anyone found a way to fix this?Im facing the same issue
@Genza999 have you tried using VersionedTransaction instead of Transaction?
Thanks, worked with the VersionedTransaction
@Genza999 have you tried using VersionedTransaction instead of Transaction?
Even if u are using VersionedTransaction, it can randomly throw "ValueError: invalid value: alias encoding, expected strict form encoding". You can try for yourself. Make several requests. Some of them will throw error
@uy5cu71 I've been using the following line to to fix the issue entirely. Since I made this adjustment this issue hasn't presented itself again.
rawTransaction = VersionedTransaction.from_bytes(base64.b64decode(swap_transaction))