Shielded Addresses

Used to transfer funds inside a privacy pool

Generate Shielded Address (pool specific)

A regular shielded address for the currently selected privacy pool (aka pool-specific address).

async generateAddress(): Promise<string>

The shielded address has a human-readable prefix to indicate which privacy pool it belongs to. Do not remove this: the address without the prefix considered invalid.

Returns

Promise returns the shielded address for the current pool.

Example

console.log(`${await zkClient.generateAddress()}`);
// output: zkbob_sepolia:MrjNRn4ja5ctEW5PVFkZDe6XG97ZNCCHtgchKGzUgbrQDYUf26PikByp61oDVD9

Generate Universal Shielded Address

A universal shielded address for use with any privacy pool (aka generic address).

async generateUniversalAddress(): Promise<string>

Returns

Promise returns the shielded address for any pool

Example

Generate Shielded Address for Another Account

You can also generate a pool-specific address for another user account. To generate, you must provide the account spending key.

Parameters

seed - spending key for the account generated address belongs to

It's the same parameter as provided in the AccountConfig.sk during the account attaching

Returns

Promise returns the shielded address for the current pool belonging to the provided spending key

Example

Shielded Address Verification

Parameters

address - pool-specific or generic shielded address

Addresses without prefixes are deprecated, the only exception is the USDC pool on Polygon where they are allowed. Otherwise, prefix-less addresses will be marked as invalid.

Returns

Promise returns true if address checksum is correct and can be used on the current privacy pool

Example

Check if a Shielded Address Belongs to an Account

Parameters

address - pool-specific or generic shielded address

Addresses without prefixes are deprecated, the only exception is the USDC pool on Polygon where they are allowed. Otherwise, prefix-less addresses will be marked as invalid.

Returns

Promise returns true if address checksum is correct, it can be used on the current privacy pool and it belongs to the current user account

Example

Get Components of a Shielded Address

Parameters

address - pool-specific or generic shielded address

Returns

Promise returns IAddressComponents for the provided address

Example

Last updated

Was this helpful?