> For the complete documentation index, see [llms.txt](https://docs.manifold.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.manifold.xyz/manifold-for-developers/resources/widgets/connect-widget/wallet-authentication.md).

# Wallet Authentication

Authenticating a wallet means verifying the user is in control of the wallet they are connecting with.  Wallet authentication is **enabled by default**, meaning that the user will be prompted to sign a message verifying their wallet once they click the 'Connect' button.

![](/files/aNQIQgVywxuQQNoTOeZB)

### Detecting Authentication&#x20;

Once the user signs the request above, two things occur:

1. A window object is added
2. A window event is emitted

#### Window Object

A window object containing the authentication state and connected address is added once a user has verified their wallet address.  The object is stored in `window.manifold`, and has the following structure:

<pre class="language-javascript"><code class="lang-javascript">{
  "isAuthenticated": true,
  "address": "&#x3C;THE WALLET ADDRESS>"
  "oauthToken": "&#x3C;THE AUTHENTICATION TOKEN>"
  "dataClient": &#x3C;An instance of the <a data-footnote-ref href="#user-content-fn-1">data client</a>>
}
</code></pre>

This object is updated if the user switches wallets or disconnects.

#### Window Events

There are two window events that are fired upon authentication and disconnect. These events can be observed by adding event listeners via `window.addEventListener`

* `m-authenticated`

  This event is fired upon authentication or if the user switches their wallet address.  The event will also contain a reference to the [Data Client](/manifold-for-developers/resources/widgets/connect-widget/data-client.md), which you can access via `event.detail.client`
* `m-unauthenticated`

  This event is fired if the user disconnects from the website by clicking the 'Disconnect' button.

  Additionally, there will be an `m-authenticated` event fired upon authentication (and `m-unauthenticated` if they click the "Disconnect" button).&#x20;

<br>

[^1]:


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.manifold.xyz/manifold-for-developers/resources/widgets/connect-widget/wallet-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
