@nymproject/sdk • Docs
@nymproject/sdk / Client
Interface: Client
Properties
start()
start: (
opts?) =>Promise<void>
Start the client.
Example
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
#### Parameters
• **opts?**: `any`
#### Returns
`Promise`\<`void`\>
#### Source
[mixnet/wasm/types.ts:33](https://github.com/nymtech/nym/blob/5065c5579e2c961211276dcdfd8aaa127f29bf26/sdk/typescript/packages/sdk/src/mixnet/wasm/types.ts#L33)
***
### stop()
> **stop**: () => `Promise`\<`void`\>
Stop the client.
#### Example
```typescript
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
await client.stop();Returns
Promise<void>
Source
mixnet/wasm/types.ts:46 (opens in a new tab)
selfAddress()
selfAddress: () =>
Promise<undefined|string>
Get the client address
Example
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
const address = await client.selfAddress();Returns
Promise<undefined | string>
Source
mixnet/wasm/types.ts:59 (opens in a new tab)
setTextMimeTypes()
setTextMimeTypes: (
mimeTypes) =>void
Set the mime-types that should be used when using the Client.send method.
Example
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
await client.setTextMimeTypes(['text/plain', 'application/json']);See
Parameters
• mimeTypes: string[]
Returns
void
Source
mixnet/wasm/types.ts:76 (opens in a new tab)
getTextMimeTypes()
getTextMimeTypes: () =>
Promise<string[]>
Get the mime-types that are automatically converted to strings.
Example
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
const mimeTypes = await client.getTextMimeTypes();See
Returns
Promise<string[]>
Source
mixnet/wasm/types.ts:93 (opens in a new tab)
send()
send: (
args) =>Promise<void>
Send some data through the mixnet message.
Example
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
await client.send({
payload: 'Hello world',
recipient: // recipient address,
});See
Parameters
• args
• args.payload: Payload
• args.recipient: string
• args.replySurbs?: number
Returns
Promise<void>
Source
mixnet/wasm/types.ts:111 (opens in a new tab)
rawSend()
rawSend: (
args) =>Promise<void>
Send a raw payload, without any mime-type conversion.
Example
const client = await createNymMixnetClient();
await client.start({
clientId: 'my-client',
nymApiUrl: 'https://validator.nymtech.net/api',
});
const payload = new Uint8Array([1, 2, 3]);
await client.rawSend({
payload,
recipient: // recipient address,
});See
Parameters
• args
• args.payload: Uint8Array
• args.recipient: string
• args.replySurbs?: number
Returns
Promise<void>