Search code examples
pythonsolanasolana-web3js

How can I serialize VersionedTransaction in Solana with python?


I built sending several txs in one jito bundle with Node.js. I want convert this code to python. When I use jito bundle, I should serialize transactions. When I use Node.js, I can use transaction.serialize(). But when I use python, I used transaction.serialize(), it occurs error.

'solders.transaction.VersionedTransaction' object has no attribute 'serialize'

How can I serialize VersionedTransaction in Solana with python?


Solution

  • It looks like VersionedTransaction implements bytes at https://github.com/kevinheavey/solders/blob/c10419c29b7890e69572f0160e5e74406814048b/python/solders/transaction.pyi#L121, so you should be able to serialize the transaction with:

    bytes(transaction)