# Accessing Accounts

To interact with the user's account in Rabet, you must first connect to it. For connecting to the user account, you must send a connection request to the user. If the user confirms, you will receive the user account public key; otherwise, you will receive an error.

```javascript
rabet.connect()
    .then(result => console.log(`User active public key is: ${result.publicKey}`))
    .catch(error => console.error(`Error: ${error}`));
```

![](/files/-MTjGVscNeSWI63jNT1S)

{% hint style="info" %}
This verification process is done only once, and when the user connects to your website, you will immediately receive the user's account public key.
{% endhint %}

{% hint style="info" %}
Try to put a connect button for the user to call the `connect` function and until the answer to one request is not specified, don't call another connect request.
{% endhint %}

{% hint style="info" %}
If the user has disabled the extension privacy mode option, there is no need to confirm the user and you will receive the account public key immediately after the call `connect` function.
{% endhint %}

### accountChanged event

If you'd like to be notified when the address changes, we have an event you can subscribe to:

```javascript
rabet.on('accountChanged', () => {
    console.log('User changed their active account!');
});
```


---

# 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.rabet.io/accessing-accounts.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.
