Authento API
  • Welcome to Authento
  • Integration Guidance
    • Introduction
    • Address-Based Verification
      • Off-Chain Access Control
      • On-Chain Access Control
        • Digital Signature Verification
        • Merkel Proof Verification
    • Account-Based Verification
    • Webhooks
  • API Reference
    • General Information
    • Endpoints
      • Get Basic User Info
      • Get Full User Info
  • Authento-react
    • Getting Started
    • useSignature
    • useStatus
    • useTokenVerifyPopup
    • useVerifyPopup
Powered by GitBook
On this page
  • Usage
  • Configuration
  • Return Value
  1. Authento-react

useSignature

A custom React hook to fetch digital signature from your backend for on-chain access control.

PreviousGetting StartedNextuseStatus

Last updated 1 year ago

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 .

Usage

import { useSignature } from "authento-react";
  
export const MyComponent = () => {
  const { refetch: getSignature } = useSignature({
    endpoint: "https://api.example.com/signature",
    onSuccess: (expireTs, signature) => {
      console.log({ expireTs, signature });
    },
    onError: (error) => {
      console.log(error);
    },
  }); 

  return (
    <div>
      <button onClick={refetch}>Generate Signature</button>
    </div>
  );
};

Configuration

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.

Return Value

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.

here