Integrate StellarCred
How it works
StellarCred stores zero-knowledge proofs on Stellar. Your protocol reads them with one contract call. No API keys, no backend, no data handling — the only thing you trust is the on-chain ProofRegistry.
Installation
npm install @stellarcred/sdkChecking a claim
The primary call. Returns true if the wallet has a valid, unexpired proof of the claim. For parameterised claims (age, income, funds), pass minThreshold to enforce the threshold on-chain — trustlessly.
import { StellarCred } from "@stellarcred/sdk";
// Binary claim (kyc, jurisdiction) — no threshold
const kycOk = await StellarCred.hasClaim(wallet, "kyc");
// Age gate — proof must have been generated with threshold_years >= 21
const ageOk = await StellarCred.hasClaim(wallet, "age", { minThreshold: 21 });
// Funds gate — proof must certify balance >= $50,000
const fundsOk = await StellarCred.hasClaim(wallet, "funds", { minThreshold: 50000 });Configuration
Call configure() once at startup, or set env vars. Both approaches work in Node.js, Next.js, and edge runtimes.
import { StellarCred } from "@stellarcred/sdk";
// Option A — explicit (recommended for servers / edge)
StellarCred.configure({
registryId: process.env.PROOF_REGISTRY_ID,
rpcUrl: "https://soroban-testnet.stellar.org",
networkPassphrase: "Test SDF Network ; September 2015",
});
// Option B — env vars (auto-read at import time)
// STELLARCRED_REGISTRY_ID=C...
// STELLARCRED_RPC_URL=https://soroban-testnet.stellar.org
// (also reads NEXT_PUBLIC_PROOF_REGISTRY_ID / NEXT_PUBLIC_RPC_URL)Redirecting users to verify
If a user hasn’t verified yet, send them to StellarCred and get them back automatically. Use claimParams to customise thresholds.
import { StellarCred } from "@stellarcred/sdk";
// KYC gate — basic redirect
const kycUrl = StellarCred.buildVerifyUrl({
returnUrl: 'https://yourapp.xyz/deposit',
claim: 'kyc',
});
// Age gate — require 21+
const ageUrl = StellarCred.buildVerifyUrl({
returnUrl: 'https://yourapp.xyz/markets',
claim: 'age',
claimParams: { threshold_years: '21' },
});
// Funds gate — require balance ≥ $50,000
const fundsUrl = StellarCred.buildVerifyUrl({
returnUrl: 'https://yourapp.xyz/vault',
claim: 'funds',
claimParams: { threshold: '50000' },
});
// When the user returns, check again:
const verified = await StellarCred.hasClaim(wallet, "kyc");Available claim types
| Claim | What it proves | Issued by |
|---|---|---|
| kyc | Identity verified | KYC provider |
| age | Age ≥ 18 (threshold configurable) | KYC provider |
| income | Income ≥ threshold | Financial data provider |
| jurisdiction | Country not restricted | KYC provider |
| funds | Balance ≥ threshold | Plaid / bank attestation |
Contract addresses
The deployed StellarCred contracts on testnet.
| NEXT_PUBLIC_ISSUER_REGISTRY_ID | CD4WNFA5SVOCZVEBXG3BNODBWNQMJRVBT6YH4J5M2FWHQ2SWMI7XWETS |
| NEXT_PUBLIC_CREDENTIAL_VERIFIER_ID | CDDSADPJRYMNLX2DTSN5OQO3XDPPIVQMU5WAPY2PWHKHAQZMMP5VK2CF |
| NEXT_PUBLIC_PROOF_REGISTRY_ID | CCB4LNZVHHBM34UNHKD2D57BENKWM27KTDNEQWYYFRPIGDNYI77QYIVO |
| NEXT_PUBLIC_GATED_POOL_ID | CC2CENI7KIKPF6TAGPORUVKGNADLP6MKIGYVSTGYOAZETOXECQ56X42O |
Calling the contract directly
Prefer Soroban? Call ProofRegistry from your own contract — no SDK required. Use is_verified for binary claims and check_claim for threshold enforcement.
// Binary claim (kyc, jurisdiction)
let registry = ProofRegistryClient::new(&env, ®istry_id);
let (verified, _, _) = registry.is_verified(&holder, &symbol_short!("kyc"));
require!(verified, Error::KycRequired);
// Parameterised claim — enforce minimum threshold on-chain
let eligible = registry.check_claim(&holder, &symbol_short!("funds"), &Some(50_000u64));
require!(eligible, Error::InsufficientFunds);