Skip to main content
Writing protobuf codec wrappers, query clients, and Amino converters by hand is error-prone and tedious. Code generation tools read your chain’s .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 implement TelescopeGeneratedType, which the CosmJS Registry accepts directly. A typical Telescope output includes:
  • Message codecs (MsgXxx with encode, decode, fromPartial)
  • Query clients (QueryClientImpl for gRPC-web queries)
  • Registry arrays (pre-built [typeUrl, codec] pairs)
  • Amino converters (ready-made AminoConverter objects)

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 the cosmjs-types package. It’s a lightweight, general-purpose protobuf code generator that produces clean TypeScript with no Cosmos-specific abstractions.

Setup

Install ts-proto and protoc (the Protocol Buffer compiler):
You also need protoc installed on your system.

Generating Code

Key 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:
Then use --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:
Runtime types from protobufjs use create instead of fromPartial. The Registry handles both automatically.

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
For production applications, Telescope or ts-proto are preferred because they provide compile-time type safety.

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.