Nimiq Albatross Light Client
A very light Nimiq Proof-of-Stake client for browsers and NodeJS, compiled from Rust to WebAssembly.
Note
This light client is intended to be used in web browsers or NodeJS only (no WASI support either). Other webworker-enabled environments are not yet supported.
📦 Installation
You need to install this package from the next
tag:
npm install @nimiq/core@next
or
yarn add @nimiq/core@next
🛠️ Usage
This package contains the WASM file bundled for three targets: bundler
, web
and node
.
With Bundlers
If you use any bundler for your project, like Webpack or Vite, you should probably use the bundler
target exported from the package root. If that doesn't work, or you require the web
target for your use-case, jump to the With ES Modules section.
[!IMPORTANT]
For Webpack 5:
- Enable the
asyncWebAssembly
experiment in your config. - Dynamically import the package with
await import()
.
[!IMPORTANT]
For Vite:
- Use the
vite-plugin-wasm
plugin. - Exclude this package from Vite's dependency optimization:
optimizeDeps: {
exclude: ['@nimiq/core'],
}
[!IMPORTANT]
For Nuxt:
- Use the
vite-plugin-wasm
plugin. - Exclude this package from Vite's dependency optimization:
vite: {
optimizeDeps: {
exclude: ['@nimiq/core'],
}
}
- Ensure the package is only run client-side: either set
ssr: false
in your Nuxt config, import this package only in client-side plugins, or wrap it in <ClientOnly>
.
const Nimiq = await import('@nimiq/core');
import * as Nimiq from '@nimiq/core';
const config = new Nimiq.ClientConfiguration();
config.network('testalbatross');
config.seedNodes(['/dns4/seed1.pos.nimiq-testnet.com/tcp/8443/wss']);
config.logLevel('debug');
const client = await Nimiq.Client.create(config.build());
With ES Modules
import init, * as Nimiq from '@nimiq/core/web';
init().then(() => {
const config = new Nimiq.ClientConfiguration();
const client = await Nimiq.Client.create(config.build());
});
NodeJS
For NodeJS, this package includes both CommonJS and ESM builds. You can either require()
the package or import
it.
const Nimiq = require("@nimiq/core");
import * as Nimiq from "@nimiq/core";
async function main() {
const config = new Nimiq.ClientConfiguration();
const client = await Nimiq.Client.create(config.build());
}
main();
🐛 Issues, Bugs and Feedback
This is an early version of the client code compiled to WebAssembly and as such there can be problems and friction, especially now that more people try it out in more environments than we could ever test ourselves.
If you encounter issues or you find a bug, please open an issue in our Github at https://github.com/nimiq/core-rs-albatross.
If you want to provide feedback or have questions about the client, our "Nimiq Coders Dojo" Telegram group and the Community Forum are the right places for that.