2

I have to send multiple transaction at once but if I will add the transaction like...

txn.add([ixn1, ixn2, ixn]); or txn.add(ixn1);txn.add(ixn2)...

So, this will handle by the solana runtime right, but there is the limit of 1232 bytes of transaction to append like this. So, I have to send multiple transaction with the transaction size more than 1232 bytes, So if I will add the transaction like this.....

txList.push(new Transaction().add(tx1Instruction)); txList.push(new Transaction().add(tx2Instruction))....

In this case, solana runtime will not handle transactions, So, How can I handle that multiple transactions which are more than txn limit size because it can be possible one transaction got error and other got succeed, how can I check if one got error and other should not be executed ?

1
  • Depends on your program design. You may need to implement workflow in your program.
    – Frank C.
    Aug 27, 2022 at 7:48

1 Answer 1

1

Send and confirm the transactions in order. If there is an error sending one of the transactions, an exception will be thrown.

try {
  for (const tx of txList) {
    const txSig = await connection.sendRawTransaction(tx.serialize(), {
      preflightCommitment: 'confirmed',
    })
    const latestBlockHash = await connection.getLatestBlockhash()
    await connection.confirmTransaction(
      {
        blockhash: latestBlockHash.blockhash,
        lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
        signature: txSig,
      },
      'confirmed',
    )
  }
} catch (error: any) {
  console.log('Error sending transactions', error)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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