How to pre-compute transaction fees? - CLOSED


Could you help me understand how to pre-calculate transaction fees when submitting transactions on the chain ?
I read this but this doesn’t help me much.

Right now, I’m trying to compute the cost of a transaction embedding “X” MsgSend messages, all signed by a single user Secp256k1 key ? (i.e. one sender transfers different amounts to multiple users in a single transaction)

I noticed that the f(x)Wallet app was able to propose a transaction fee before the transaction was approved, and would like to be able to do the same.
I eventually ended up with the following formula :
GasFee = 28263.2 + NbMessages * 102.3

But I’m pretty sure there is something smarter available…

Thanks in advance for your help.

hey @Mdmdmd83

not sure if this helps, but you can add a --dry-run flag to a ‘tx’ command and it will return a gas estimate.

I’m trying to do it programmatically.
But this morning, I was trying to use the Cosmos SDK tx.simulate command… I think I’m not far from the solution that is used in the fxcored CLI --dry-run command, but still… I didn’t manage to do it yet.
Thanks anyway, @magicOctopus !

I finally found out gRPC SimulateRequest and SimulateResponse messages.
Topic closed.