3

So lets say I have an unsigned transaction. Is there any way I can simulate the transaction without actually sending it to the chain to see if the transaction will fail or if it will be succesfull? Basically something like estimateGas on EVM chains.

2 Answers 2

1

you can try validate_transaction by calling into the runtime api using the client that you can get handle from outer node

or

from https://polkadot.js.org/apps/#/explorer -> developer -> Runtime calls -> taggedTransactionQueue -> validate_transaction .

5
  • Can I do this via polkadotjs? May 16, 2023 at 10:07
  • @TadejVengust yes, what didn't you understood with my answer regarding using polkadotjs?
    – dadzerlaze
    May 16, 2023 at 10:08
  • By polkadot js I ment polkadot SDK so progamatically via javascript. May 16, 2023 at 10:12
  • 1
  • I tried to implement this but it don't quite understand the parameters. This expects 3 parameters which are: - source (local, inBlock, external) - tx - blockHash I want to verify if a transaction will be successful or not. Don't understand why I would need to provide a block hash? Can't find any docs or examples of the usage. Can you provide some? Jul 6, 2023 at 9:10
0

You can use an RPC call to Dry run an extrinsic at a given block. You can construct this with PolkadotJS very easily with tx.dryRun, see an example here: https://substrate.stackexchange.com/a/2913/2762

However this is an unsafe RPC call and not all the nodes has it activated, if you are running your own node you can activate it with a flag: Unsafe RPC calls?

You can use Sidecar too that exposes an endpoint to dry run a extrinsic.

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.