0

i know it is possible, but not exactly sure the best implementation currently, whether to use CPI or not, to have a solana tx, execute on chain and have 1 instruction in there effectively execute another transaction to start on chain, and maybe have another instruction there to wait for confirmation that the 2nd one completed, before continuing.

The 2nd transaction needs to be non-atomically linked.

So first transaction executes, does an instruction, gets another tx to start and finish, continues on with additional steps. What is the easiest and most effective way to do this? Would a custom CPI be required or could it be done without one?

1 Answer 1

0

In your transaction object, you can add instruction a, that will execute first. Then, in instruction b, you can add an instruction by your own program, which makes a CPI call to send a new transaction.

By default, you cannot trigger another transaction with an instruction with-in an earlier transaction, you'd need to use CPI for this on program side.

Anchor CPI docs: https://book.anchor-lang.com/anchor_in_depth/CPIs.html

More about transactions: https://solana.com/docs/core/transactions

1
  • can doing it this way ensure non-atomic linking between the 2 txs? whats the best way to ensure that, whilst ensuring the 2nd tx starts at the desired time (ie after instruction a), and the 1st tx does not proceed to the next instruction until after that tx is completed
    – Bobby Lee
    Commented May 14 at 7:59

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.