Skip to content

API Reference

This page documents the public types, props, and hooks exported by @averer/averer-websdk.


AvererSdkProvider

The provider component that wraps your application and initialises the SDK.

<AvererSdkProvider configId="your-config-id">{children}</AvererSdkProvider>

Props:

  • configId (string, required): your Averer configuration ID. Contact Averer support to obtain one.

AvererWebSdk

The main SDK component that renders the verification flow UI.

type AvererWebSdkProps = {
  appName: string;
  mode?: 'individual' | 'business';
  sdkQuery: SdkQuery;
  onChainMetaData?: {
    contract_address: string;
    method_id: string;
  };
  onSuccess?: (data: SdkSuccessRes) => void;
  onError?: (reason: string) => void;
};
Prop Type Required Description
appName string Yes Name of your application, displayed in the SDK UI.
mode 'individual' \| 'business' No Verification flow mode. Defaults to 'individual'. Use 'business' for KYB.
sdkQuery SdkQuery Yes Eligibility criteria the user must satisfy.
onChainMetaData object No If provided, SDK submits proofs on-chain. method_id should be 'b68967e2' (submitZKPResponse V1) or 'ade09fcd' (submitZKPResponseV2).
onSuccess function No Callback fired when all queries are successfully proven.
onError function No Callback fired when the user cancels, rejects, or an error occurs.

useAvererWallet

A React hook that provides access to the user's embedded wallet. Must be used within an AvererSdkProvider.

import { useAvererWallet } from '@averer/averer-websdk';

const wallet = useAvererWallet();

Returns an object with:

Property / Method Type Description
address string The user's blockchain wallet address.
getPublicClient() () => Promise<PublicClient> Returns a Viem Public Client for read-only blockchain operations.
getWalletClient() () => Promise<WalletClient> Returns a Viem Wallet Client for signing and sending transactions.
getBalance() () => Promise<string> Returns the wallet's token balance.
signMessage(message) (message: string) => Promise<string> Signs an arbitrary message with the wallet's private key.
ensureMfaForSigning() () => Promise<void> Checks if MFA is required before signing or sending a transaction. Call before signMessage or sendTransaction.

Returns null if the wallet is not yet connected.


SdkQuery

The type for defining eligibility criteria.

type SdkQuery = Array<{
  id: number;
  circuitId: string;
  subjectTitle: string;
  optional?: boolean;
  query: ZeroKnowledgeProofQuery;
  params?: {
    nullifierSessionId?: string | number;
  };
}>;
Field Type Description
id number A unique numeric identifier for the query. For on-chain queries, this must match the requestId on the verifier contract.
circuitId string Circuit used for proof generation. Use credentialAtomicQuerySigV2 for off-chain or credentialAtomicQuerySigV2OnChain for on-chain.
subjectTitle string Short title describing the verification purpose (e.g. "18+ Years Old").
optional boolean If true, this query is not required for the overall eligibility check to pass.
query ZeroKnowledgeProofQuery The proof requirements and constraints.
params object Optional parameters. nullifierSessionId can be used for nullifier-based proofs.

ZeroKnowledgeProofQuery

The type for defining proof requirements within a query.

type ZeroKnowledgeProofQuery = {
  allowedIssuers: string[];
  context: string;
  credentialSubject?: JsonDocumentObject;
  proofType?: string;
  skipClaimRevocationCheck?: boolean;
  groupId?: number;
  type: string;
};
Field Type Description
allowedIssuers string[] List of issuer DIDs permitted to provide the credential. Use ['*'] to allow any issuer.
context string JSON-LD context URL defining the credential schema.
credentialSubject object Conditions or fields to verify. Use operators like $eq, $lt, $gt, $in for conditions, or an empty object {} for selective disclosure.
proofType string Optional proof type override.
skipClaimRevocationCheck boolean If true, skips the credential revocation check. Useful for testing but not recommended in production.
groupId number Optional group identifier for linking related queries.
type string The credential type (e.g. AMLCTFCredential, EssentialIdCredential).

SdkSuccessRes

The type returned in the onSuccess callback when verification completes.

type SdkSuccessRes = {
  walletAddress: string;

  user: {
    email?: string;
    isAuthenticated: boolean;
    did?: string;
  };

  proofs: Array<{
    id: string | number;
    circuitId: string;
    subjectTitle: string;
    status: 'valid' | 'failed';
    proofData: {
      credentialType: string;
      rawProof?: {
        id: number | string;
        circuitId: string;
        vp?: {
          type: string;
          verifiableCredential: {
            type: string | string[];
            credentialSubject: JsonDocumentObject;
          };
        };
      };
    };
  }>;

  eligibility: {
    passed: boolean;
    summary: string;
  };

  onChain?: {
    contract_address: string;
    method_id: string;
    chain_id: number;
    network?: string;
    txHash?: string;
  };
};
Field Description
walletAddress The user's blockchain wallet address.
user.email The user's email address, if available.
user.isAuthenticated Whether the user is authenticated.
user.did The user's Decentralized Identifier, if available.
proofs Array of proof results, one per query.
proofs[].status 'valid' if the proof was accepted, 'failed' otherwise.
proofs[].proofData.rawProof.vp.verifiableCredential.credentialSubject The actual credential data proven by the user (e.g. age, nationality).
eligibility.passed true if the user satisfied all required proof checks.
eligibility.summary Human-readable summary of the eligibility result.
onChain Present only in on-chain mode.
onChain.txHash The transaction hash, useful for showing "submitted / confirmed" UX.