Created
September 30, 2021 23:13
-
-
Save beautyfree/3a66c56d2b755f2cef38a77de9eb817d to your computer and use it in GitHub Desktop.
Solana snippet to show raw signed txs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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