# Establish Connection

Before you interact with Blocto, you have to establish a connection first. The connection will prompt the user for permission to share their public key, or it returns public key directly if the user has approved the account access permission.

## Connection

```javascript
window.solana.connect()
```

When the user has approved the request to connect, the provider will emit a `connect` event. And you may access useful properties of the provider.

```javascript
window.solana.on("connect", () => console.log("connected"))

window.solana.publicKey // wallet's publicKey
window.solana.connected // true or false
window.solana.network // mainnet-beta or testnet
```

## Disconnection

Similar with connection, calling disconnection will emit a `disconnect` event.

```javascript
window.solana.disconnect()

window.solana.on("disconnect", () => console.log("disconnected"))
```


---

# 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.blocto.app/~/changes/lJG0Ie43hDo96Dq7BMVa/blocto-app/web3.js-integration-solana/establish-connection.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.
