---
description: >-
  The Monitor Module is useful to poll for changes, e.g. on the blockchain,
  especially for confirmations of transactions.
---

# Monitor Module

{% hint style="warning" %}
This module is still in an experimental stage
{% endhint %}

### Installation

{% tabs %}
{% tab title="npm" %}
```
npm i @signumjs/monitor
```
{% endtab %}

{% tab title="yarn" %}
```
yarn add @signumjs/monitor
```
{% endtab %}

{% tab title="<script/>" %}
```html
<script src='https://cdn.jsdelivr.net/npm/@signumjs/monitor/dist/signumjs.monitor.min.js'></script>
```

The namespace is `sig$monitor`

```javascript
// Create an account monitor
const monitor = new sig$monitor.Monitor({
   asyncFetcherFn: tryFetchAccount,
   compareFn: checkIfAccountExists,
   intervalSecs: 10, // polling interval in seconds
   key: 'monitor-account',
   timeoutSecs: 2 * 240 // when reached timeout the monitor stops
})
.onFulfilled(() => {
   // called when `checkIfAccountExists` returns true
   console.log('Yay, account active');
})
.onTimeout(() => {
   // called when `timeoutSecs` is reached
   console.log('Hmm, something went wrong');
}).start();
```
{% endtab %}
{% endtabs %}

### API Reference

{% embed url="https://signum-network.github.io/signumjs/modules/monitor.html" %}
