Skip to main content
Every transaction message in Cosmos SDK is identified by a type URL (e.g. "/cosmos.bank.v1beta1.MsgSend") and encoded as Protocol Buffers. The Registry in @cosmjs/proto-signing maps type URLs to their codec implementations so CosmJS can encode and decode messages.

Adding Types to the Registry

Start from defaultRegistryTypes, which includes all standard Cosmos SDK message types, and add your own:
Now signAndBroadcast can serialize MsgCreatePost messages:

Registering Multiple Types

When your module has several message types, define them as an array and spread into the registry:

Supported Codec Formats

The Registry accepts types generated by any of these tools: All four implement encode and decode. Types with fromPartial (Telescope, ts-proto) are preferred because they allow constructing messages from partial objects without specifying every field. See the Code Generation page for details on each tool.

Type-Safe Encode Objects

For large projects, define typed encode objects that narrow the typeUrl to a string literal. This prevents typos and gives you autocomplete on the value field:
Use them when constructing transactions:

Decoding Transactions

The Registry also decodes incoming data. This is useful for parsing transactions from the blockchain or decoding responses:
Without your custom types registered, registry.decode throws Unregistered type url for unknown message types. Register all types you expect to encounter before decoding.

Next Steps

Query Extensions

Build typed query methods for your custom module.

Amino Converters

Add Amino JSON signing support for wallets like Keplr and Leap.

Code Generation

Generate TypeScript codecs from protobuf definitions automatically.