# Connect

In order to start interacting with Broearn Wallet, an app must first establish a connection. This connection request will prompt users for permission to share their public keys, indicating that they are willing to interact further.

Once a user connects to Broearn Wallet, Broearn Wallet will return the promise type param that should be used on all subsequent methods.

### Query Function

```javascript
// New Connect
window.bw.put.connect()
// Check if the Dapp is linked to a wallet
window.bw.put.connect({
    session: '...'
}}
```

### Query String Parameters

Check if the Dapp is linked to a wallet

```javascript
// Some code
{
    session: string
}
```

### Returns

#### Approve

* `data`: An JSON object.

  ```json
  // content of decrypted `data`-parameter
  {
    // base58 encoding of user public key
    "address": "BSFtCudCd4pR4LSFqWPjbtXPKSNVbGkc35gRNdnqjMCU",

    // session token for subsequent signatures and messages
    // dapps should send this with any other deeplinks after connect
    "session": "..."
  }
  ```

  * address: The public key of the user, represented as a base58-encoded string.
  * `session`: A string type. This should be treated as opaque by the connecting app, as it only needs to be passed alongside other parameters. Sessions do not expire.

```
// Sample code
{
    "data": {
        "address": "",
        "session": ""
    }
}
```

#### Reject

An `errorCode` and `errorMessage` as query parameters. Please refer to [Errors](/errors.md) for a full list of possible error codes.

```json
{
    "errorCode": "",
    "errorMessage": ""
}
```


---

# 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://wallet-docs.broearn.com/provider-methods/connect.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.
