> For the complete documentation index, see [llms.txt](https://docs.endless.link/endless/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.endless.link/endless/endless-wallet/wallet-adapter/events.md).

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