# Global variables

The global variables are all available in the `window` instances on browsers.

```typescript
interface Window {
  // Sentre
  sentre: {
    wallet?: import('@senswap/sen-js').WalletInterface
    lamports: import('@senswap/sen-js').Lamports
    splt: import('@senswap/sen-js').SPLT
    swap: import('@senswap/sen-js').Swap
  }
  // Utility
  notify: ({ type, description, onClick }: SentreNotification) => void
  message: ({ type, description, onClick }: SentreMessage) => void
}
```

## Global sentre

```typescript
window.sentre = {
  wallet?: import('@senswap/sen-js').WalletInterface
  lamports: import('@senswap/sen-js').Lamports
  splt: import('@senswap/sen-js').SPLT
  swap: import('@senswap/sen-js').Swap
}
```

{% hint style="info" %}
The following instances are from sen-js. See [sen-js APIs](https://descartesnetwork.github.io/sen-js/) for details.
{% endhint %}

| Property | Type                         | Description        |
| -------- | ---------------------------- | ------------------ |
| wallet   | WalletInterface \| undefined | Wallet instance.   |
| lamports | Lamports                     | Lamports instance. |
| splt     | SPLT                         | SPLT instance.     |
| swap     | Swap                         | Swap instance.     |

## Global notification

To create top-right notifications.

```typescript
window.notify = ({ type, description, onClick }: SentreNotification) => void

type SentreNotification = {
  type: 'error' | 'warning' | 'success' | 'info'
  description: string
  onClick?: () => void
}

window.message = ({ type, description, onClick }: SentreMessage) => void

type SentreMessage = {
  type: 'error' | 'warning' | 'success' | 'info' | 'loading'
  description: string
  onClick?: () => void
}
```

#### API

| Property    | Type                                           | Description                                                               |
| ----------- | ---------------------------------------------- | ------------------------------------------------------------------------- |
| type        | error \| warning \| success \| info \| loading | The notification type.                                                    |
| description | string                                         | The notification message.                                                 |
| onClick     | function \| undefined                          | The action that is activated when users click to the notification pop-up. |

#### Examples

```typescript
// To pop an error message on Coin98 connection failure
window.message({
  type: 'error',
  description: 'Coin98 Wallet is not connected.',
})

// To pop an warning notification on Phantom installation and direct to Phantom homepage
window.notify({
  type: 'warning',
  description: 'Phantom Wallet is not installed.',
  onClick: () => window.open('https://phantom.app/', '_blank'),
})
```


---

# 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.sentre.io/development/global-variables.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.
