# Sign a Multisig Transaction

A web application may request Adena to sign a multisig transaction via the SignMultisigTransaction method. This method allows authorized signers to add their signature to an unsigned transaction. Each signer can download their signature file (.sig) to share with the transaction initiator for final broadcasting.

Note: Unlike the UI-based signing method where you upload .tx files, the injection method manages all transaction data through code.

### Code

```javascript
adena.SignMultisigTransaction(
  multisigDocument: MultisigTransactionDocument,
  multisigSignatures?: Signature[],
  withSaveFile?: boolean
)
```

### Params

| Key                | Type         | Description                                                              |
| ------------------ | ------------ | ------------------------------------------------------------------------ |
| multisigDocument   | object       | Multisig Transaction Document Model                                      |
| multisigSignatures | Signature\[] | Array of existing signatures (optional)                                  |
| withSaveFile       | boolean      | Flag to automatically save the signature file (optional, default: false) |

#### Multisig Transaction Document Model

| Key           | Type   | Description                                                                |
| ------------- | ------ | -------------------------------------------------------------------------- |
| tx            | RawTx  | The raw transaction object containing messages, fees, signatures, and memo |
| chainId       | string | The chain ID of the target blockchain (e.g., "staging", "portal-loop")     |
| accountNumber | string | The account number of the multisig account                                 |
| sequence      | string | The sequence number of the multisig account                                |

#### Signature Model

| Key             | Type   | Description                                   |
| --------------- | ------ | --------------------------------------------- |
| pub\_key        | object | Public key object                             |
| pub\_key.\@type | string | Public key type (e.g., "/tm.PubKeySecp256k1") |
| pub\_key.value  | string | Base64-encoded public key                     |
| signature       | string | Base64-encoded signature                      |

### Response

| Key     | Type   | Description                            |
| ------- | ------ | -------------------------------------- |
| code    | number | Response code (success: 0)             |
| status  | string | Returns "success" or "failure"         |
| type    | string | Response type                          |
| message | string | Descriptive message of the result      |
| data    | object | Sign Multisig Transaction Result Model |

#### Sign Multisig Transaction Result Model

| Key                       | Type                        | Description                                                   |
| ------------------------- | --------------------------- | ------------------------------------------------------------- |
| result                    | object                      | Result object containing multisig document and all signatures |
| result.multisigDocument   | MultisigTransactionDocument | The original multisig transaction document                    |
| result.multisigSignatures | Signature\[]                | Array of all collected signatures                             |
| signature                 | Signature                   | The current signer's signature                                |

### Sample Request

```javascript
await adena.SignMultisigTransaction({
  tx: {
    msg: [
      {
        "@type": "/bank.MsgSend",
        from_address: "g1ksdqtg675y28vkua8zrghxzlgwtpyxwklp5gpf",
        to_address: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        amount: "2ugnot"
      },
    ],
    fee: {
      gas_wanted: "6112955",
      gas_fee: "6113ugnot",
    },
    signatures: null,
    memo: "",
  },
  accountNumber: "6224",  // Replace it with the accountNumber of your multisig account.
  sequence: "1",          // Replace it with the sequence of your multisig account.
  chainId: "staging",     // Replace your target chainId
}, [], true);
```

### Sample Response

```json
{
  "code": 0,
  "status": "success",
  "type": "SIGN_MULTISIG_TRANSACTION_SUCCESS",
  "message": "Multisig transaction has been successfully signed.",
  "data": {
    "result": {
      "multisigDocument": {
        "tx": {
          "msg": [
            {
              "@type": "/bank.MsgSend",
              "from_address": "g1ksdqtg675y28vkua8zrghxzlgwtpyxwklp5gpf",
              "to_address": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
              "amount": "2ugnot"
            }
          ],
          "fee": {
            "gas_wanted": "6112955",
            "gas_fee": "6113ugnot"
          },
          "signatures": null,
          "memo": ""
        },
        "accountNumber": "6224",
        "sequence": "1",
        "chainId": "staging"
      },
      "multisigSignatures": [
        {
          "pub_key": {
            "@type": "/tm.PubKeySecp256k1",
            "value": "A+FhNtsXHjLfSJk1lB8FbiL4mGPjc50Kt81J7EKDnJ2y"
          },
          "signature": "..."
        }
      ]
    },
    "signature": {
      "pub_key": {
        "@type": "/tm.PubKeySecp256k1",
        "value": "A+FhNtsXHjLfSJk1lB8FbiL4mGPjc50Kt81J7EKDnJ2y"
      },
      "signature": "..."
    }
  }
}
```


---

# 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.adena.app/integrations/transactions/sign-a-multisig-transaction.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.
