C# / .NET SDK
Installation
dotnet add package CrowdProof.SDK
Requires .NET 8+.
Initialization
using CrowdProof.SDK;
var client = new CrowdProofClient("cp_live_abc123...");
Dependency Injection
builder.Services.AddCrowdProof(options =>
{
options.ApiKey = builder.Configuration["CrowdProof:ApiKey"];
});
Then inject ICrowdProofClient into your services.
Reputation Scores
// Single score
var score = await client.GetScoreAsync("0x1234...", "DEFI_LENDING");
Console.WriteLine($"Score: {score.Score}, Tier: {score.Tier}");
// All categories
var all = await client.GetAllScoresAsync("0x1234...");
foreach (var s in all.Scores)
Console.WriteLine($"{s.Category}: {s.Score}");
// Batch query
var batch = await client.BatchQueryAsync(
new[] { "0x1234...", "0x5678..." },
"DEFI_LENDING"
);
ZK Proofs
// Generate
var proof = await client.GenerateProofAsync(new ProofRequest
{
Subject = "0x1234...",
ProofType = "ScoreAboveThreshold",
Category = "DEFI_LENDING",
Threshold = 700
});
// Verify
var result = await client.VerifyProofAsync(proof.Proof);
Console.WriteLine($"Valid: {result.Valid}");
Identity (DID)
// Register
var did = await client.RegisterDIDAsync("0x1234...", chainId: 1);
// Resolve
var resolved = await client.GetDIDAsync("did:ethr:0x1234...");
Error Handling
try
{
var score = await client.GetScoreAsync("invalid", "DEFI_LENDING");
}
catch (CrowdProofException ex)
{
Console.WriteLine($"Error {ex.StatusCode}: {ex.Message}");
if (ex.StatusCode == 429)
await Task.Delay(TimeSpan.FromSeconds(ex.RetryAfter));
}