useSignature
A custom React hook to fetch digital signature from your backend for on-chain access control.
Last updated
A custom React hook to fetch digital signature from your backend for on-chain access control.
Last updated
To make use of this hook, you must set up an endpoint which takes an address string as a query parameter and returns a digital signature along with an expire timestamp. A reference implementation can be found .
The useSignature
hook accepts a configuration object with the following options:
endpoint
(required): Your own endpoint for digital signature.
onSuccess (optional): This function will fire when the digital signature is fetched successfully
onError (optional): This function will fire when the signature request encounters an error.
The useSignature
hook returns an object with the following properties:
signature
: A string representing the digital signature generated. It will be undefined
initially and will be updated with the fetched signature when available.
expireTs
: A number representing the Unix timestamp (in seconds) used to generate the digital signature. It will be undefined
initially and will be updated with the fetched value when available.
refetch
: A function that can be called to manually trigger a refetch of the digital signature.