1

Let's say you're checking out some simulated transactions, with sigVerify set to false, is there some nice way to print out account balances (SPL token and/or Sol) in the simulated transaction universe before and after the transaction? The program logs only give very cursory information, like the transfer was a success.

  const simulationResult = await provider.connection.simulateTransaction(
    transaction,
    {
      sigVerify: false,
    }
  );

Maybe there's some handy instruction for printing out balances that exists?

2 Answers 2

1

It looks like pre and post token balances are not included in simulation results unfortunately, the same as they are for getTransaction. It might be worth adding those.

In the meantime, you can look through all of the top-level and inner instructions for token transfers, and then reverse them to get the pre balances.

The post balances are included in the accounts field from simulateTransaction

1
  • Very helpful thanks. Sounds like a lot of work but the information is there, it's just not well surfaced
    – Henry E
    Apr 2 at 13:25
1

You could probably add a print my token instruction in a program that you deploy and add the instruction before and after your actual instruction you are interested in.

1
  • Yeh, it seems like the only solution here for now.
    – Henry E
    Apr 2 at 13:25

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.