# useSignMessage

Since Comet accounts come with a built-in cloud wallet, you can use this wallet to cryptographically sign messages on behalf of the user using the `useSignMessage` hook. The user will be prompted to log in if necessary, and will be asked to confirm the message to be signed (similar to the flow for Metamask or Phantom wallets).

<figure><img src="/files/vHqxkGcx44rcboxl1saD" alt=""><figcaption></figcaption></figure>

## API

```javascript
const { signMessage } = useSignMessage({ message: '<MESSAGE>' });
```

`signMessage` is a function that can be called later on, which will bring up the confirmation dialog. It returns a successful `Promise` containing the signed message, or a failed `Promise` if the user clicks "Cancel".

## Example

{% code title="App.js" %}

```tsx
import { useSignMessage } from '@comet-labs/react';

function App() {
  const { signMessage } = useSignMessage({ message: 'gm world' });

  return (
    <div className="App">
      <button onClick={signMessage}>
        click here to sign message
      </button>
    </div>
  );
}
```

{% endcode %}


---

# 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://comet-3.gitbook.io/comet-sdk/reference/comet-sdk-reference/comet-react-sdk/hooks/usesignmessage.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.
