2

For example, if I wanted to use Metaplex's Program Library to do something on their program, and wanted to create a front end for it and include a small Solana fee for my work, is it possible to put that all into one transaction instead of multiple (one for fee and one for program)?

Any responses are greatly appreciated :)

1 Answer 1

5

Something similar to this should suit your purposes:

let tx1 = await program.methods
  .tallyVotes()
  .accounts({
    config: configPDA,
    campaign: campaignPDA,
  })
  .signers([])
  .instruction();

let tx2 = await program.methods
  .startNextRound(new anchor.BN(450))
  .accounts({
    fundstarter: user.publicKey,
    campaign: campaignPDA,
    nextRound: round2PDA,
  })
  .signers([user])
  .instruction();

let transaction = new anchor.web3.Transaction();
await transaction.add(tx1);
await transaction.add(tx2);

const signature = await anchor.web3.sendAndConfirmTransaction(
   provider.connection,
   transaction,
   [user]
);

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.