@nymproject/nodejs-client-commonjs
v1.2.4-rc.1
Published
This package is a NodeJS client that uses the wasm from the [Sphinx webassembly client](https://github.com/nymtech/nym/blob/4890c528bcb519290de81ef968bb2ba1399914a4/wasm/client/README.md), runs it inside a NodeJS Worker thread and allows users to send and
Downloads
6
Readme
Nym NodeJS wrapper for Sphinx webassembly client
This package is a NodeJS client that uses the wasm from the Sphinx webassembly client, runs it inside a NodeJS Worker thread and allows users to send and receive Sphinx packets to/from a Nym mixnet.
Usage
const { createNymMixnetClient } = require('@nymproject/nodejs-client-commonjs');
async () => {
const nym = await createNymMixnetClient();
nym.events.subscribeToTextMessageReceivedEvent(async (e) => {
console.log("message received", e.args.payload);
});
const nymApiUrl = 'https://validator.nymtech.net/api/';
// start the client and connect to a gateway
await nym.client.start({
nymApiUrl,
clientId: 'my-client',
});
nym.events.subscribeToConnected(async (e) => {
// send a message to yourself
const message = 'Hello';
const recipient = await nym.client.selfAddress();
await nym.client.send({ payload: { message, mimeType: 'text/plain' }, recipient });
});
};