I am using Magic Eden's API to generate a buy transaction, and it returns the bytes of the transaction. I'm using Python, solanapy
and solders
to send the transaction. However I don't know how to interpret the bytes and send them. Here is my code:
msg = VersionedTransaction.from_bytes(bytes(data[0]))
sig = wallet.sign_message(bytes(msg.message))
msg.verify_and_hash_message()
response = httpClient.send_transaction(
txn=msg,
opts=TxOpts(skip_preflight=False, skip_confirmation=True),
)
Where data[0]
is the list of bytes that is returned by Magic Eden. This code gives me the error:
msg.verify_and_hash_message()
solders.TransactionError: Transaction did not pass signature verification
If I remove the verify, it compiles but the signature is 1111.....111
. Any help is appreciated.
EDIT: I now have this, which seems to be very close to the actual solution however I'm getting this error New code:
raw_tx = VersionedTransaction.from_bytes(bytes(data[0]))
signature = wallet.sign_message(to_bytes_versioned(raw_tx.message))
signed_tx = VersionedTransaction.populate(raw_tx.message, [signature])
txid = httpClient.send_transaction(
signed_tx,
opts=TxOpts(skip_confirmation=False, skip_preflight=False),
).value
Error when sending transaction:
solana.rpc.core.RPCNoResultException: invalid transaction: Transaction failed to sanitize accounts offsets correctly
data
as its result?