> ## Documentation Index
> Fetch the complete documentation index at: https://cosmos-docs-cosmjs-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Message Types

> Registering custom Protobuf and Amino message types in CosmJS

CosmJS registers all standard Cosmos SDK message types by default. If your chain
has custom modules with their own message types, you need to register them.

## Registering Custom Types

```typescript theme={"system"}
import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { defaultRegistryTypes, SigningStargateClient, GasPrice } from "@cosmjs/stargate";
import { MsgCreatePost } from "./generated/blog/tx";

const wallet = await DirectSecp256k1HdWallet.fromMnemonic("your mnemonic ...", {
  prefix: "cosmos",
});
const [{ address }] = await wallet.getAccounts();

const registry = new Registry(defaultRegistryTypes);
registry.register("/blog.v1.MsgCreatePost", MsgCreatePost);

const client = await SigningStargateClient.connectWithSigner(
  "https://rpc.my-chain.network",
  wallet,
  { registry, gasPrice: GasPrice.fromString("0.025utoken") },
);

const msg = {
  typeUrl: "/blog.v1.MsgCreatePost",
  value: MsgCreatePost.fromPartial({
    author: address,
    title: "Hello from CosmJS",
    body: "This is a custom message type.",
  }),
};

const result = await client.signAndBroadcast(address, [msg], "auto");
```

## Amino Support for Custom Types

If your custom messages also need Amino signing (e.g. for Ledger support), you
need to register Amino converters alongside the Protobuf registry:

```typescript theme={"system"}
import {
  AminoTypes,
  createDefaultAminoConverters,
  SigningStargateClient,
  GasPrice,
} from "@cosmjs/stargate";
import { Registry } from "@cosmjs/proto-signing";

const aminoTypes = new AminoTypes({
  ...createDefaultAminoConverters(),
  "/blog.v1.MsgCreatePost": {
    aminoType: "blog/MsgCreatePost",
    toAmino: (value) => ({
      author: value.author,
      title: value.title,
      body: value.body,
    }),
    fromAmino: (value) => ({
      author: value.author,
      title: value.title,
      body: value.body,
    }),
  },
});

const client = await SigningStargateClient.connectWithSigner(
  "https://rpc.my-chain.network",
  wallet,
  { registry, aminoTypes, gasPrice: GasPrice.fromString("0.025utoken") },
);
```

Reuse the `registry` built in the previous section (or create a fresh `Registry(defaultRegistryTypes)` and register your custom protobuf type on it) when passing this to `connectWithSigner`.
