> ## 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.

# EncodeObject

> The JavaScript representation of Cosmos SDK messages in CosmJS

In CosmJS, the JavaScript representation of a type-URL-tagged message is an
`EncodeObject`:

```typescript theme={"system"}
interface EncodeObject {
  readonly typeUrl: string;
  readonly value: any;
}
```

You construct one by pairing a type URL with a partial Protobuf message:

```typescript theme={"system"}
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { coins } from "@cosmjs/proto-signing";

const msg: EncodeObject = {
  typeUrl: "/cosmos.bank.v1beta1.MsgSend",
  value: MsgSend.fromPartial({
    fromAddress: "cosmos1sender...",
    toAddress: "cosmos1recipient...",
    amount: coins(1_000_000, "uatom"),
  }),
};
```

## Typed Encode Objects

CosmJS also provides **typed encode objects** for common messages. These narrow
the `typeUrl` to a string literal and constrain `value` to the correct Protobuf
type, giving you compile-time safety:

```typescript theme={"system"}
import { MsgSendEncodeObject } from "@cosmjs/stargate";

const msg: MsgSendEncodeObject = {
  typeUrl: "/cosmos.bank.v1beta1.MsgSend",
  value: MsgSend.fromPartial({ ... }),
};
```

### Available in `@cosmjs/stargate`

| Type                                     | typeUrl                                                   |
| ---------------------------------------- | --------------------------------------------------------- |
| `MsgSendEncodeObject`                    | `/cosmos.bank.v1beta1.MsgSend`                            |
| `MsgDelegateEncodeObject`                | `/cosmos.staking.v1beta1.MsgDelegate`                     |
| `MsgUndelegateEncodeObject`              | `/cosmos.staking.v1beta1.MsgUndelegate`                   |
| `MsgBeginRedelegateEncodeObject`         | `/cosmos.staking.v1beta1.MsgBeginRedelegate`              |
| `MsgWithdrawDelegatorRewardEncodeObject` | `/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward` |
| `MsgDepositEncodeObject`                 | `/cosmos.gov.v1beta1.MsgDeposit`                          |
| `MsgSubmitProposalEncodeObject`          | `/cosmos.gov.v1beta1.MsgSubmitProposal`                   |
| `MsgVoteEncodeObject`                    | `/cosmos.gov.v1beta1.MsgVote`                             |
| `MsgTransferEncodeObject`                | `/ibc.applications.transfer.v1.MsgTransfer`               |

### Available in `@cosmjs/cosmwasm`

| Type                                  | typeUrl                                     |
| ------------------------------------- | ------------------------------------------- |
| `MsgStoreCodeEncodeObject`            | `/cosmwasm.wasm.v1.MsgStoreCode`            |
| `MsgInstantiateContractEncodeObject`  | `/cosmwasm.wasm.v1.MsgInstantiateContract`  |
| `MsgInstantiateContract2EncodeObject` | `/cosmwasm.wasm.v1.MsgInstantiateContract2` |
| `MsgExecuteContractEncodeObject`      | `/cosmwasm.wasm.v1.MsgExecuteContract`      |
| `MsgMigrateContractEncodeObject`      | `/cosmwasm.wasm.v1.MsgMigrateContract`      |
| `MsgUpdateAdminEncodeObject`          | `/cosmwasm.wasm.v1.MsgUpdateAdmin`          |
| `MsgClearAdminEncodeObject`           | `/cosmwasm.wasm.v1.MsgClearAdmin`           |
