Home Reference Source Test
public class | source

Nimiq

Entry class and dynamic loader for the Nimiq library in Browsers.

When using NodeJS, you don't need this class. Just require the nimiq library.

Example:

Browser usage
<script type="text/javascript" src="https://cdn.nimiq.com/core/nimiq.js></script>
<script type="text/javascript">
    Nimiq.init(function(core) {
        console.log(core.wallet.address);
    }, function(errorCode) {
        console.log("Error initializing core.");
    }, options)
</script>
Browser usage (experimental)
<script type="text/javascript" src="https://cdn.nimiq.com/core/nimiq.js></script>
<script type="text/javascript">
    async function init() {
        await Nimiq.load();
        const core = await new Nimiq.Core(options);
        console.log(core.wallet.address);
    }
    init();
</script>
NodeJS usage
const Nimiq = require('nimiq');
const core = await new Nimiq.Core(options);
console.log(core.wallet.address);

Static Method Summary

Static Public Methods
public static

init(ready: function(), error: function(errorCode: number))

Initialize the Nimiq client library.

public static

load(path: string): Promise

Load the Nimiq library.

public static

loadOffline(path: string): Promise

Load the reduced offline version of the Nimiq library.

public static

loadToScope(classes: ...string): Promise<void>

Load classes into scope (so you don't need to prefix them with Nimiq.).

Static Public Methods

public static init(ready: function(), error: function(errorCode: number)) source

Initialize the Nimiq client library.

Params:

NameTypeAttributeDescription
ready function()

Function to be called once the library is available.

error function(errorCode: number)

Function to be called when the initialization fails.

public static load(path: string): Promise source

Load the Nimiq library.

Params:

NameTypeAttributeDescription
path string
  • optional
  • nullable: true

Path that contains the required files to load the library.

Return:

Promise

Promise that resolves once the library was loaded.

public static loadOffline(path: string): Promise source

Load the reduced offline version of the Nimiq library.

Params:

NameTypeAttributeDescription
path string
  • optional
  • nullable: true

Path that contains the required files to load the library.

Return:

Promise

Promise that resolves once the library was loaded.

public static loadToScope(classes: ...string): Promise<void> source

Load classes into scope (so you don't need to prefix them with Nimiq.).

Params:

NameTypeAttributeDescription
classes ...string

Array of class names to load in global scope

Return:

Promise<void>