SDK Reference

checkAttestation()

Read the on-chain AttestationRecord PDA for a wallet. This is the one function every dApp calls on every page load. If it returnsverified: true, your user is a verified Nigerian adult and you have done zero KYC.

Signature

checkAttestation(
  walletAddress: string,
  network?: 'devnet' | 'mainnet-beta'
): Promise<AttestationStatus>

What this function does

  1. Derives the AttestationRecord PDA from walletAddress. Seeds: ["africazk-attestation", wallet_pubkey].
  2. Reads the account from the chosen Solana network.
  3. If the account does not exist: returns { verified: false }.
  4. If the account exists: deserialises verified, timestamp, and revoked fields.
  5. If revoked is true: returns { verified: false }.
  6. Otherwise: returns the verified status with timestamp and protocol version.

Returns

AttestationStatus
type AttestationStatus =
  | { verified: false }
  | {
      verified: true
      verifiedAt: number      // unix ms
      protocol: 'Althea-v1'
      attestationPDA: string  // base58 PDA address
    }

When to call this

  • On every page load after the wallet connects.
  • Before rendering any identity-gated feature.
  • After submitProof() completes to confirm the attestation exists on-chain.

Cache the result

checkAttestation() makes one RPC call to Solana. Cache the result for the duration of the session — by user pubkey — and do not call it on every render. Re-check only on wallet change, on a manual refresh action, or after a successful submitProof().

Example — a React hook

useAfricaZKStatus.ts
'use client'

import { useEffect, useState } from 'react'
import { checkAttestation, type AttestationStatus } from '@africazk/identity'

export function useAfricaZKStatus(walletAddress?: string) {
  const [status, setStatus] = useState<AttestationStatus | null>(null)

  useEffect(() => {
    if (!walletAddress) {
      setStatus(null)
      return
    }
    let cancelled = false
    checkAttestation(walletAddress, 'mainnet-beta').then((s) => {
      if (!cancelled) setStatus(s)
    })
    return () => {
      cancelled = true
    }
  }, [walletAddress])

  return status
}

Server-side usage

checkAttestation() works in any environment with fetch and @solana/web3.js available — including Next.js Route Handlers and Edge runtimes. Use it server-side to gate sensitive operations, but remember the attestation only proves the wallet is verified, not that the request comes from that wallet. Combine with a signed message.

Errors

This function only throws on RPC failures (network down, invalid endpoint). It does not throw on verified: false — that is a normal result for unverified wallets.

See also