Skip to main content
When you call StargateClient.connect() or connectComet(), CosmJS auto-detects the node’s CometBFT version so it can use the correct RPC protocol.

How Auto-Detection Works

1

Initial connection

CosmJS connects a Tendermint 0.37 client and calls status().
2

Version check

It reads nodeInfo.version from the response.
3

Client selection

If the version starts with 0.38., it disconnects and reconnects with Comet38Client. If it starts with 1., it reconnects with Comet1Client. Otherwise, it keeps the 0.37 client.
This costs one extra RPC round-trip on startup.

Skipping Auto-Detection

If you already know your chain’s CometBFT version, skip auto-detection by constructing the client directly:
Skipping auto-detection saves one RPC round-trip on every client creation. This is worth doing in production when you know the chain’s CometBFT version.

Using connectComet Directly

You can also use connectComet on its own when you need a CometClient without a high-level wrapper:

Next Steps

Connect to a Chain

Return to the connection overview and transport selection table.

Custom Endpoints

Combine manual client construction with custom headers and batching.