# Events

## 1. Endless Wallet initialization completion event

The init event is executed after the wallet initialization is completed. For example, the getAccount method needs to be called after the init event is completed.

```javascript
import { EndLessSDKEvent } from '@endlesslab/endless-web3-sdk';

jssdk.on(EndLessSDKEvent.INIT, async () => {
  const getAccountRes = await jssdk.getAccount();
  if (
    getAccountRes.status === UserResponseStatus.APPROVED &&
    getAccountRes.args.account
  ) {
    // getAccountRes.args.account is the address of the wallet
    conosole.log('getAccountRes =====>', getAccountRes);
  }
});
```

## 2. Endless Wallet network change event

Network Change is executed when the user switches networks in the wallet and returns network information.

```javascript
jssdk.on(EndLessSDKEvent.NETWORK_CHANGE, (networkInfo) => {
  console.log('networkInfo', networkInfo);
});
```

## 3. Endless Wallet account change event

Account Change is executed when the user switches the current wallet in the wallet and returns the wallet address.

```javascript
jssdk.on(EndLessSDKEvent.ACCOUNT_CHANGE, (accountAddress) => {
  console.log('accountChange', accountAddress);
  if (accountAddress.account) {
    setAccountAddress(accountAddress.account);
  }
});
```

## 4. Endless Wallet connect event

The connect event is executed when the user links the current dapp in the wallet.

```javascript
import { EndLessSDKEvent } from '@endlesslab/endless-web3-sdk';

jssdk.on(EndLessSDKEvent.CONNECT, (res) => {
  console.log('connect', res);
});
```

## 5. Endless Wallet disconnect event

The disconnect event is executed when the user disconnects from the dapp link in the wallet.

```javascript
import { EndLessSDKEvent } from '@endlesslab/endless-web3-sdk';

jssdk.on(EndLessSDKEvent.DISCONNECT, (res) => {
  console.log('disconnect', res);
});
```

## 6. Endless Wallet open event

The open event is executed when the user open the wallet window in the wallet.

```javascript
import { EndLessSDKEvent } from '@endlesslab/endless-web3-sdk';

jssdk.on(EndLessSDKEvent.OPEN, () => {
  console.log('wallet opened');
});
```

## 7. Endless Wallet close event

The closes event is executed when the user closes the wallet window in the wallet.

```javascript
import { EndLessSDKEvent } from '@endlesslab/endless-web3-sdk';

jssdk.on(EndLessSDKEvent.CLOSE, () => {
  console.log('wallet closed');
});
```


---

# 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.endless.link/endless/endless-wallet/wallet-adapter/events.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.
