Skip to main content


Finds a 64 bit nonce that matches the specified difficulty. This function generates hashes using the supplied data, optional data identifier and timestamp. When a hash is found that satisfies the specified difficulty, this becomes the nonce that is returned. The powVerify function can be used to verify a nonce.


This function can be used to prevent form spamming.


data: Instance | Context | {
exportables: Export.IExportables;
actionables: Export.IActionables | undefined;
difficulty: number,
id?: string,
length: 8 | 16 | 24 | 32,
timeout?: number,
timestamp: number,
timestampResolution: "seconds" | "milliseconds"
): string


dataInstance | Context | objectNoSpecifies the data to find the nonce for. If an Instance or Context is supplied, the data is automatically retrieved. It is also possible to supply the data directly using the exportables and actionables functions from the export module.
difficultynumberNoSpecifies the difficulty (a good average starting difficulty is 10).
idstringYesOptional identifier for the data.
length8 | 16 | 24 | 32YesSpecifies the nonce length (default is 16).
timeoutnumberYesSpecifies a timeout in milliseconds (disabled by default).
timestampnumberYesSpecifies the timestamp to use as the number of milliseconds since the ECMAScript epoch (default is the current time).
timestampResolution"seconds" | "milliseconds"YesSpecifies if the timestamp has seconds or milliseconds resolution.

Return value

Returns the nonce hash string.


This function throws an error if the work is not completed successfully.