I am trying to call the same smart contract function in a loop using web3/solana. Currently I have to sign the transaction on every iteration. How do I make it so that I sign only once and the loop runs

  • you need to provide code to get a high quality answer. there are too many unknowns as presented
    – trent.sol
    Aug 19, 2022 at 6:11

2 Answers 2


you need to build a custom Transaction that calls the program multiple times. Calling that transaction will produce multiple cpi calls. But you have to keep in mind the computation limit.


If you're working on a web app, you might be looking for the signAllTransactions function: https://github.com/solana-labs/wallet-adapter/blob/4c600d6763a02927c3c590d1a24fb62fa38758db/packages/core/react/src/useWallet.ts#L62

This is from the @solana/wallet-adapter package, specifically the export from useWallet hook. This will allow the wallet (if it supports that) to sign multiple transactions at the same time.

However, it makes more sense to add multiple calls to your program within a single transaction if you can.

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.