0

I'm using the jupiter swap api (https://station.jup.ag/docs/apis/swap-api) to perform token swaps and they return a versionedTransaction object which I hope to set the fee payer to a specific wallet.

I know that I can set the feepayer of the legacy transaction object, but I don't see a similar field for the new versionedTransaction object.

1 Answer 1

1

You can use TransactionMessage.decompile on the VersionedTransaction's inner VersionedMessage to get back everything https://github.com/solana-labs/solana-web3.js/blob/master/packages/library-legacy/src/transaction/message.ts#L35

This would look roughly like:

const versionedTx = // get it from API
const decompiledMessage = TransactionMessage.decompile(versionedTx.message);
decompiledMessage.feePayer = // whatever you want
const newVersionedTx = new VersionedTransaction(decompiledMessage.compileToV0Message());
// sign your new transaction with all signers

Note that this isn't perfect and might not work -- if there are any signatures in the provided transaction, they will be lost and invalid if you modify the underlying message. This holds for legacy and v0 transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.