ntv-sdk
v1.1.12
Published
The Nym SDK for Typescript will get you creating apps that can use the Nym Mixnet and Coconut credentials quickly.
Downloads
20
Readme
Nym SDK (Typescript)
The Nym SDK for Typescript will get you creating apps that can use the Nym Mixnet and Coconut credentials quickly.
TL;DR
Include the SDK in your project:
npm install @nymproject/sdk
Open a connection to a Gateway on the Nym Mixnet:
import { createNymMixnetClient } from '@nymproject/sdk';
const main = async () => {
const nym = await createNymMixnetClient();
const nymApiUrl = 'https://validator.nymtech.net/api';
// show message payload content when received
nym.events.subscribeToTextMessageReceivedEvent((e) => {
console.log('Got a message: ', e.args.payload);
});
// start the client and connect to a gateway
await nym.client.start({
clientId: 'My awesome client',
nymApiUrl,
});
// send a message to yourself
const payload = 'Hello mixnet';
const recipient = nym.client.selfAddress();
nym.client.send({ payload, recipient });
};
This will start the WASM client on a worker thread, so that your code can stay nice and snappy.
Send a message to another user (you will need to know their address at a Gateway):
const payload = 'Hello mixnet';
const recipient = '<< RECIPIENT ADDRESS GOES HERE >>';
await nym.client.send({ payload, recipient });