.proto files and produce TypeScript code that’s directly compatible with CosmJS’s Registry, createProtobufRpcClient, and AminoTypes.
Choosing a Generator
Telescope
Telescope is the most popular code generator in the Cosmos ecosystem. It produces complete TypeScript libraries that include everything needed for CosmJS integration — message codecs, query clients, Amino converters, and registry arrays.Quick Start
Telescope v2 has been published as
@hyperweb/telescope with InterchainJS as the default dependency. For CosmJS-based projects, @cosmology/telescope v1.x remains the recommended version. The CLI commands below work with both versions.Using Telescope Output with CosmJS
Telescope-generated types implementTelescopeGeneratedType, which the CosmJS Registry accepts directly. A typical Telescope output includes:
- Message codecs (
MsgXxxwithencode,decode,fromPartial) - Query clients (
QueryClientImplfor gRPC-web queries) - Registry arrays (pre-built
[typeUrl, codec]pairs) - Amino converters (ready-made
AminoConverterobjects)
Chain-Specific Libraries
Many popular chains already have Telescope-generated libraries published on npm:
Check if a library exists for your chain before generating types from scratch.
ts-proto
CosmJS itself uses ts-proto via thecosmjs-types package. It’s a lightweight, general-purpose protobuf code generator that produces clean TypeScript with no Cosmos-specific abstractions.
Setup
Installts-proto and protoc (the Protocol Buffer compiler):
protoc installed on your system.
Generating Code
ts_proto_opt options:
The generated
MsgXxx and QueryClientImpl classes work directly with CosmJS’s Registry and createProtobufRpcClient.
Working with Yarn 2+
The binary./node_modules/.bin/protoc-gen-ts_proto is not easily available in Yarn 2+. Create an executable wrapper script bin/protoc-gen-ts_proto_yarn_2:
--ts_proto_yarn_2_opt instead of --ts_proto_opt in your protoc command. See the cosmjs-types repo for a full example.
protobufjs (Runtime Types)
For prototyping or when you don’t have access to.proto files, protobufjs lets you define types at runtime in pure JavaScript — no build step required:
When to Use protobufjs
- Prototyping: Quickly test a message type without setting up a codegen pipeline
- Dynamic schemas: When the proto definitions aren’t known at build time
- Plain JavaScript: When you don’t want a TypeScript build step
Next Steps
Custom Protobuf Types
Register your generated types in the CosmJS Registry.
Custom Modules
Wire generated types into a complete module integration.
Supporting New Chains
Configure CosmJS for your chain’s address prefix, gas token, and account type.