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:
<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>
<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>
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: Array<string>): Promise<void> Load classes into scope (so you don't need to prefix them with |
Static Public Methods
public static init(ready: function(), error: function(errorCode: number)) source
Initialize the Nimiq client library.
Params:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
path | string |
|
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:
Name | Type | Attribute | Description |
path | string |
|
Path that contains the required files to load the library. |
Return:
Promise | Promise that resolves once the library was loaded. |
public static loadToScope(classes: Array<string>): Promise<void> source
Load classes into scope (so you don't need to prefix them with Nimiq.
).
Params:
Name | Type | Attribute | Description |
classes | Array<string> | Array of class names to load in global scope |
Return:
Promise<void> |