# Generate Msg Contents

### **Building the Msgs**

You can build out the transaction from the exported Proto type definitions from our SDK. This allows you to create transactions with multiple Msg types in one tx. See [here](https://github.com/BitBadges/bitbadgesjs/tree/main/packages/bitbadgesjs-sdk/src/proto) for all proto Msg definitions.

```typescript
import { proto } from 'bitbadges';

//proto.cosmos.module for standard Cosmos
//proto.tokenization for BitBadges x/tokenization
const MsgDeleteCollection = proto.tokenization.MsgDeleteCollection;
const MsgCreateCollection = proto.tokenization.MsgCreateCollection;
const MsgUpdateCollection = proto.tokenization.MsgUpdateCollection;
const MsgTransferTokens = proto.tokenization.MsgTransferTokens;

const protoMsgs = [
    new MsgDeleteCollection({ collectionId: '1', creator: 'bb...' }),
    //Add more here (executed in order)
];
```

### Building the Transaction

```typescript
import { TxContext, createTransactionPayload } from 'bitbadges';

const txContext: TxContext = { ... } //See prior page

const txnPayload = createTransactionPayload(txContext, protoMsgs);
```

The outputted payload will be in the following format.

```typescript
export interface TransactionPayload {
    legacyAmino: {
        body: TxBody;
        authInfo: AuthInfo;
        signBytes: string;
    };
    signDirect: {
        body: TxBody;
        authInfo: AuthInfo;
        signBytes: string;
    };
    // Optional: EVM transaction details (present when evmAddress is provided in TxContext)
    evmTx?: {
        to: string;        // Precompile address (0x1001, 0x1002, or 0x1003)
        data: string;      // Encoded function call data
        value: string;     // Always "0" for precompiles
        functionName: string; // Function name for debugging
    };
}
```

**EVM Support:**

When you provide an `evmAddress` in the `TxContext`, the SDK automatically converts supported messages to EVM precompile calls. The `evmTx` field will be populated with the EVM transaction details. See [Signing - Ethereum](/for-developers/create-and-broadcast-txs/signing-ethereum.md) for complete details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bitbadges.io/for-developers/create-and-broadcast-txs/generate-msg-contents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
