Simulate Tx
atmoner opened this issue ยท 3 comments
Hello!
Is it possible to use the SimulateRequest endpoint?
I saw some functions in proto.js but I don't know how to use them
https://docs.cosmos.network/v0.42/core/proto-docs.html#cosmos.tx.v1beta1.SimulateRequest
Thanks ๐
You need to create SignDoc.
signDoc = (1)txBody + (2)authInfo
Every authInfo will be same when you use only 1 address. You should create SimulateRequest txbody.
You can see msgSend code here.
https://github.com/cosmostation/cosmosjs/blob/ca760c89c50af40d0f6a50852ea61f8e16c2f982/example/cosmoshub.js
For creating SimulateRequest txBody, you can search the proto structure at here.
https://github.com/cosmostation/cosmosjs/blob/ca760c89c50af40d0f6a50852ea61f8e16c2f982/src/messages/proto.js
Thank you for your answer @Booyoun-Kim
I tried a lot of things without success!
If you have an example for me, I could better understand how proto works and help you with the documentation.
But I need an example please
@atmoner Here's the message structure of SimulateRequest.
const rawMsg = new cosmos.tx.v1beta1.SimulateRequest({
tx: tx,
tx_bytes: txBytes,
});
return new google.protobuf.Any({
type_url: '/cosmos.tx.v1beta1.SimulateRequest',
value: cosmos.tx.v1beta1.SimulateRequest.encode(rawMsg).finish()
});