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
- SDK builds a Solana transaction with proof + public signals.
- User signs with their wallet (Phantom, Backpack, etc.).
- Althea Anchor program receives the transaction.
- Program checks valid === 1.
- Program checks Ax/Ay match the Althea public key embedded in the program.
- NullifierRecord PDA is derived and initialised. If the PDA already exists the transaction fails - this is the duplicate-identity guard.
- AttestationRecord PDA is derived and initialised. Stores verified=true, timestamp, protocol="Althea-v1".
- 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 / Code | Cause | Recovery |
|---|---|---|
| Duplicate nullifier | This identity already has an attested wallet — the NullifierRecord PDA exists | Show user the existing verified wallet; do not re-verify |
| Invalid proof | Public signals or Ax/Ay rejected by the Anchor program | Restart from verifyIdentity() — proof was tampered or malformed |
| User rejected | User cancelled the wallet signature prompt | Show a clear retry CTA — no on-chain state changed |
| Insufficient SOL | Wallet does not have enough lamports for rent + fee | Prompt user to fund the wallet (≈ 0.001 SOL is enough) |
| Blockhash expired | Transaction built too long ago | SDK 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
- The Anchor program — instruction layout and account constraints.
- checkAttestation() — read the attestation that was just created.