# Usage

Once you have added SignumJS to your application you usually want to connect to one of the Signum Network nodes to interact with the blockchain.&#x20;

All you need is to create an API instance to get access to the methods of the blockchain API.

The following example shows how to get an account from the chain.

{% tabs %}
{% tab title="Javascript" %}
{% code title="index.js" %}
```javascript
const {composeApi} = require('@signumjs/core');

(async () => {
    const api = composeApi({
        nodeHost: 'https://europe.signum.network',
    });

    const account = await api.account.getAccount({accountId: '16107620026796983538'});
    console.log('Account', account);
})();

```
{% endcode %}


{% endtab %}

{% tab title="Typescript" %}
{% code title="index.ts" %}
```typescript
import {composeApi} from '@signumjs/core';

(async (): Promise<void> => {
    const api = composeApi({
        nodeHost: 'https://europe.signum.network',
    });

    const account = await api.account.getAccount({accountId: '16107620026796983538'});
    console.log('Account', account);
})();
```
{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
It is essential to understand the concept of [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) and [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) in Javascript. Many functions of SignumJS require to communicate with remote servers and therefore you need to be familiar with asynchronous Javascript.
{% endhint %}

## Usage with bundles

When using the bundles imported via [\<script/>](../installation#install-via-less-than-script-greater-than), you need to use the respective _namespace_ to get access to the any of the functions within a module.&#x20;

{% code title="index.html" %}
```html
<html lang="en">
<head>
    <link rel="stylesheet" href="css/styles.css">
    <!-- Importing the bundles from the CDN -->
    <script type="application/javascript"
            src='https://cdn.jsdelivr.net/npm/@signumjs/core/dist/signumjs.min.js'></script>
</head>
<body>
    <!-- your body -->
    <script type="application/ecmascript" src="src/main.js"></script>
</body>
```
{% endcode %}

{% code title="main.js" %}
```javascript
(async () => {
    // the 'namespace' of @signum/core is sig$
    const api = sig$.composeApi({
        nodeHost: 'https://europe.signum.network',
    });

    const account = await api.account.getAccount({accountId: '16107620026796983538'});
    console.log('Account', account);
})();
```
{% endcode %}

{% hint style="info" %}
The modules are bundled using [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE), to avoid global naming collisions with your application. Keep also in mind, that the bundles do not contain any type information, so your IDE cannot help you with auto-completion.&#x20;
{% endhint %}

Each module of SignumJS comes with its own _namespace_

<table><thead><tr><th width="174.63100576553495">Module</th><th width="174.81838919534852">Namespace</th><th>Example</th></tr></thead><tbody><tr><td>core</td><td><code>sig$</code></td><td><pre class="language-javascript"><code class="lang-javascript">const api = sig$.composeApi({
        nodeHost: 'https://europe.signum.network',
    });
</code></pre></td></tr><tr><td>contracts</td><td><code>sig$contracts</code></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">const dataView = new sig$contracts.ContractDataView(contract)
</code></pre></td></tr><tr><td>crypto</td><td>si<code>g$crypto</code></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">const hash = sig$crypto.hashSHA256("test")
</code></pre></td></tr><tr><td>http</td><td><code>sig$http</code></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">const client = new sig$http.HttpClientFactory.createHttpClient('https://jsonplaceholder.typicode.com/');
</code></pre></td></tr><tr><td>monitor</td><td><code>sig$monitor</code></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">const monitor = new sig$monitor.Monitor&#x3C;Account>({
    asyncFetcherFn: tryFetchAccount,
    compareFn: checkIfAccountExists,
    intervalSecs: 10, 
        key: 'monitor-account',
    timeoutSecs: 2 * 240 
})
</code></pre></td></tr><tr><td>util</td><td><code>sig$util</code></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">const value = sig$util.Amount.fromSigna("1000")
</code></pre></td></tr></tbody></table>
