1

in my program i have a function which mutates some accounts and calculate a value A, i was retrieving this value by parsing the logs, but the issue is on the UI side it requires a signature from the user ,is there a way to simulate tx without valid signatures ?

3 Answers 3

1

You need to pass "sigVerify":false with the simulateTransaction options,

4
  • Sadly though in the current web3 library this option isn't exposed
    – Henry E
    Commented Jul 25, 2022 at 18:38
  • Sounds like a great opportunity to contribute to the repo!
    – trent.sol
    Commented Jul 25, 2022 at 18:50
  • lol, isn't there already someone from solana working on a new web3 library
    – Henry E
    Commented Jul 25, 2022 at 19:01
  • all i've seen is a proposal. getting a two-liner in for this option in the meantime would likely still be valuable
    – trent.sol
    Commented Jul 25, 2022 at 19:05
0

According to the source, the signatures verification should automatically be skipped if no signers are provided. Maybe a wallet is passed as a signer automatically in your code, triggering the check?

3
  • i guess i need to clear this up here, the actual progrma ix does require some signers but i was hoping if there was a way to skip actual signatures by those users in a bid to simulateTx without having it popup approve repeatedly on the phantom UI Commented Jul 25, 2022 at 11:37
  • Hmm. Not sure I understand the distinction. Either the signatures are verified and you need to provide the ones required, or they are not like in the case of a simulation and it does not matter what sigs the ix requires outside of simulation?
    – man0s
    Commented Jul 25, 2022 at 12:32
  • now that i think of it i believe it is not possible, but what i wanted to do was , simulate an arbitary tx even in the case if required signatures which i could not give , just for the sake of simulation, but i believe this kind of tx will fail validation and hence is not possible, Commented Jul 25, 2022 at 15:57
0

There's still no way to provide a config with a legacyTx using solana/Web3. But, after hours of pulling my own hair out I found that passing undefined for the list of signers:

const simulation = await connection.simulateTransaction(
   transaction,
   undefined,
   [pubkey]
 );

This allows you to pass the list of accounts you want to see simulation data for, but will not attempt to sign the TX. This is a terrible design choice if it was intentional, but it works.

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.