Skip to content

Instantly share code, notes, and snippets.

@beautyfree
Created September 30, 2021 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beautyfree/3a66c56d2b755f2cef38a77de9eb817d to your computer and use it in GitHub Desktop.
Save beautyfree/3a66c56d2b755f2cef38a77de9eb817d to your computer and use it in GitHub Desktop.
Solana snippet to show raw signed txs
const blockhash = await swapClient.program.provider.connection.getRecentBlockhash();
let txss = txs.map((r) => {
let tx = r.tx;
let signers = r.signers;
if (signers === undefined) {
signers = [];
}
tx.feePayer = swapClient.program.provider.wallet.publicKey;
tx.recentBlockhash = blockhash.blockhash;
signers
.filter((s) => s !== undefined)
.forEach((kp) => {
tx.partialSign(kp);
});
return tx;
});
const signedTxs = await swapClient.program.provider.wallet.signAllTransactions(txss);
for (let k = 0; k < txs.length; k += 1) {
const tx = signedTxs[k];
const rawTx = tx.serialize();
console.log('rawTx:', rawTx.toString('base64'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment