SDK Reference

submitProof()

Submit a generated ZK proof to the Althea Anchor program on Solana. The user signs the transaction with their wallet. On success, two PDAs are initialised on-chain and your dApp can read the user's attestation forever after.

Signature

submitProof(
  proof: ZKProof,
  wallet: WalletAdapter,
  network?: 'devnet' | 'mainnet-beta'
): Promise<SubmitResult>

What happens on-chain

  1. SDK builds a Solana transaction with proof + public signals.
  2. User signs with their wallet (Phantom, Backpack, etc.).
  3. Althea Anchor program receives the transaction.
  4. Program checks valid === 1.
  5. Program checks Ax/Ay match the Althea public key embedded in the program.
  6. NullifierRecord PDA is derived and initialised. If the PDA already exists the transaction fails - this is the duplicate-identity guard.
  7. AttestationRecord PDA is derived and initialised. Stores verified=true, timestamp, protocol="Althea-v1".
  8. Returns txSignature, nullifier, attestationPDA, nullifierPDA.

Result

SubmitResult
type SubmitResult = {
  txSignature: string         // base58 Solana transaction signature
  nullifier: string           // same as proof.publicSignals[1]
  attestationPDA: string      // PDA address of the new AttestationRecord
  nullifierPDA: string        // PDA address of the new NullifierRecord
  slot: number                // confirmation slot
}

Errors

Message / CodeCauseRecovery
Duplicate nullifierThis identity already has an attested wallet — the NullifierRecord PDA existsShow user the existing verified wallet; do not re-verify
Invalid proofPublic signals or Ax/Ay rejected by the Anchor programRestart from verifyIdentity() — proof was tampered or malformed
User rejectedUser cancelled the wallet signature promptShow a clear retry CTA — no on-chain state changed
Insufficient SOLWallet does not have enough lamports for rent + feePrompt user to fund the wallet (≈ 0.001 SOL is enough)
Blockhash expiredTransaction built too long agoSDK retries automatically; surface only if all retries fail

Example

submit-proof-example.ts
import { submitProof } from 'afrzk-sdk'
import { useWallet } from '@solana/wallet-adapter-react'

const wallet = useWallet()
const result = await submitProof(proof, wallet, 'mainnet-beta')

console.log('Submitted at slot', result.slot)
console.log('https://explorer.solana.com/tx/' + result.txSignature)

Network parameter

Defaults to mainnet-beta. Use'devnet' during development — both networks have their own Althea program deployment and Anchor IDL.

Cost

Each successful verification costs roughly 0.0008 – 0.0012 SOL at current Solana mainnet fees. Most of that is rent exemption for the two PDAs; the transaction fee itself is a few thousand lamports.

See also