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

# Sign Message

> Sign an EIP-191 message using the unified MiniKit API.

Use `MiniKit.signMessage()` to request a personal signature from the user's wallet.

## Basic Usage

<CodeGroup>
  ```tsx title="Example" theme={null}
  import { MiniKit } from "@worldcoin/minikit-js";
  import type {
    CommandResultByVia,
    MiniAppSignMessageSuccessPayload,
    MiniKitSignMessageOptions,
  } from "@worldcoin/minikit-js/commands";

  export async function signMessage() {
    const input = {
      message: "Hello world",
    } satisfies MiniKitSignMessageOptions;

    const result: CommandResultByVia<MiniAppSignMessageSuccessPayload> =
      await MiniKit.signMessage(input);

    console.log(result.data.signature);
  }
  ```

  ```ts title="Type" theme={null}
  type MiniKitSignMessageOptions = {
    message: string;
    fallback?: () => unknown;
  };
  ```
</CodeGroup>

## Result

<CodeGroup>
  ```ts title="Type" theme={null}
  type SignMessageResponse =
    | {
        executedWith: "minikit" | "wagmi";
        data: {
          status: "success";
          version: number;
          signature: string;
          address: string;
        };
      }
    | {
        executedWith: "fallback";
        data: unknown;
      };
  ```

  ```json title="Example" theme={null}
  {
    "executedWith": "minikit",
    "data": {
      "status": "success",
      "version": 1,
      "signature": "0xabcdef1234567890",
      "address": "0x1234567890123456789012345678901234567890"
    }
  }
  ```
</CodeGroup>

## Fallback Behavior

Define a custom fallback in the command payload for support outside mini apps.

## Notes

Verify signatures in a trusted environment before using them for sensitive application logic.

## Error Codes

| Code              | Meaning                        |
| ----------------- | ------------------------------ |
| `invalid_message` | The message payload is invalid |
| `user_rejected`   | The user rejected the request  |
| `generic_error`   | Unexpected failure             |
