0

Is it even possible to accept a signed transaction as an input parameter for a program?

For example, there's an API which gives a signed transactions as a result. I need to execute that transaction alongside my own transaction (kinda wrap two transactions into another) so if either of them fail, none should get executed.

1 Answer 1

0

I need to execute that transaction alongside my own transaction (kinda wrap two transactions into another) so if either of them fail, none should get executed.

This should be possible. Technically, you would be executing two instructions inside a single transaction, and the transaction would revert if either of the instructions reverted. This distinction is shown in the below diagram, taken from here:

anatomy of a solana tx

Simply, instructions are what actually make state changes in the blockchain, and can be thought of as calls to programs. For example, a user can transfer their SPL tokens through a transfer instruction. Transactions are packages of instructions that users send to validators.

A tutorial for sending multiple instructions in a single transaction can be found in the Solana Cookbook.

2
  • thanks! it all makes sense. But the problem is that the API gives already signed transaction. I can't do anything with it, otherwise it will invalidate the signature. Hence the question is how do I pack a transaction inside another transaction. Commented Sep 15, 2022 at 20:46
  • 1
    If you can't re-sign a new transaction, it's not possible because all transactions are independent of each other and only instructions can have guaranteed atomicity
    – Proph3t
    Commented Sep 15, 2022 at 22:21

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.