Skip to main content

powVerify

Verifies a nonce generated with the powSolve function.

info

This function can be used to prevent form spamming.

Signature

powVerify(
nonce: string,
difficulty: number,
validity: number,
data: Instance | Context | {
exportables: Export.IExportables;
actionables: Export.IActionables | undefined;
},
id?: string
): boolean

Parameters

NameTypeOptionalDescription
noncestringNoSpecifies the nonce to verify. This nonce is generated with the powSolve function.
difficultynumberNoSpecifies the required difficulty (this should match the given difficulty to the powSolve function).
validitynumberNoSpecifies the maximum validity period for the nonce in milliseconds (or 0 to disable). This indicates how old the nonce may be.
dataInstance | Context | objectNoSpecifies the data used in the powSolve function. 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.
idstringYesOptional identifier for the data used in the powSolve function.

Return value

Returns true when the nonce is valid.