# Near DApps Integration

## To detect MapNode Extension with Near

To detect whether your browser is running MapNode Extension, please use:

```javascript
if(window.mapnode || window.mapnode.near || window.near?.isMapNode){
    console.log('MapNode Extension is installed!');›
}
```

Notice: MapNode Extension Testnet is under development and not available now.

Support `window.near only` and removal `window.web3`

***

## To connect MapNode Extension Wallet

To connect MapNode Extension means to access the user's \[blockchain - like Near] account(s).

```javascript
// Connect DApps
window.MapNode.near.connect(<Prefix: optional>,<Contract ID: optional>);
// Get Account
window.MapNode.near.selectedAddress;
// Get Full Accounts State
window.MapNode.near.request({ method: 'near_accountState' });
// Check if DApps connected
window.MapNode.near.isConnected();
```

***

## To disconnect MapNode Extension Wallet

To disconnect MapNode Extension, please use:

```
window.MapNode.near.disconnect()
```

## To experience functions

Once your account is connected, let's start experiencing more functions.‌

### Call View Method

```javascript
const params = {
    contractId: 'token.v2.ref-finance.near',
    method: 'ft_balance_of',
    args: {
        account_id: account
    }
}
const balance = await window.MapNode?.near.request({method: 'near_view', params})
console.log("Your near wallet balance ", balance)
```

### SignAndSend Transaction

```javascript
const params = {
    transactions,
    receiver: account
}

const result = await window.MapNode?.near.request({method: 'near_signAndSendTransaction', params})
const balance = await window.MapNode?.near.request({method: 'near_view', params})
console.log("Your near wallet balance ", balance)
```

## To handle events

### List of events

Currently we only support some action event from wallet extension

```javascript
window.mapnode.sol.on('event_name', callback);
​//Example
window.mapnode.sol.on('close', () => window.location.reload());
window.mapnode.sol.on('accountsChanged', () => window.location.reload());
```

<table><thead><tr><th width="184.0317835309541">Events</th><th>Trigger</th></tr></thead><tbody><tr><td>accountsChanged</td><td>Receive when active account changed in Extension</td></tr><tr><td>networkChanged</td><td>Receive when active network changed in Extension</td></tr><tr><td>chainChanged</td><td>Receive when active chain changed in Extension</td></tr><tr><td>disconnect</td><td>Receive when disconnect from Extension</td></tr><tr><td>close</td><td>Alias for disconnect event</td></tr></tbody></table>

<table><thead><tr><th width="359.9860751564186">Method</th><th>Description</th></tr></thead><tbody><tr><td>on(event, callback)</td><td>Add event listener</td></tr><tr><td>off(event, callback)</td><td>Remove event listener</td></tr></tbody></table>


---

# 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.mapnode.io/developer-guide/near-dapps-integration.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.
