A suite of .NET libraries for abstracting tamper-evident, append-only blockchain ledger operations, with comprehensive support for Microsoft Azure Confidential Ledger.
- Overview
- Features
- Installation
- Quick Start
- Usage Examples
- Configuration
- Target Frameworks
- Building from Source
- Documentation
- License
NuvTools.Blockchain provides a clean, intuitive abstraction layer for writing and reading typed records to a blockchain ledger. The library follows a provider pattern, allowing you to implement custom ledger backends while maintaining a consistent API.
The core library defines the foundational abstractions:
ILedgerService- Interface for writing entries to and reading entries from a ledgerLedgerEntry<T>- Typed entry returned from the ledger, includingTransactionIdand optionalCollectionIdLedgerEntryBase<T>- Base wrapper carrying the originalContentandCommitTimeUtc
Azure Confidential Ledger implementation:
AzureConfidentialLedgerService- FullILedgerServiceimplementation backed byAzure.Security.ConfidentialLedgerBlockchainSection- Strongly-typed configuration POCO bound to theNuvTools.Blockchainconfiguration sectionBlockchainExtensions.AddBlockchain()- Dependency injection registration extension- Authentication via
DefaultAzureCredential(managed identity, environment, Visual Studio, Azure CLI, etc.) - Built-in retry with linear backoff while entries are in the
Loadingstate (eventual consistency) - Automatic JSON serialization of payloads
- Lazy client initialization
✅ Provider Pattern - Easy to implement custom ledger backends
✅ Async/Await - Fully asynchronous API with CancellationToken support
✅ Generic Type Support - Write and read any serializable type
✅ Azure Integration - Production-ready Azure Confidential Ledger implementation
✅ Collection / Sub-Ledger Support - Organize entries by collectionId
✅ Eventual-Consistency Retry - Configurable retry while the ledger commits the entry
✅ Automatic Serialization - Records are serialized to JSON transparently
✅ Comprehensive Documentation - Full XML documentation for IntelliSense
✅ Multi-Targeting - Supports .NET 8, 9, and 10
Install via NuGet Package Manager:
# Core library
dotnet add package NuvTools.Blockchain
# Azure Confidential Ledger implementation
dotnet add package NuvTools.Blockchain.AzureOr via Package Manager Console:
Install-Package NuvTools.Blockchain
Install-Package NuvTools.Blockchain.Azure1. Configure appsettings.json:
{
"NuvTools.Blockchain": {
"LedgerEndpoint": "https://your-ledger-name.confidential-ledger.azure.com"
}
}2. Register services in Program.cs:
using NuvTools.Blockchain.Azure;
builder.Services.AddBlockchain(builder.Configuration);3. Inject ILedgerService and use it:
using NuvTools.Blockchain;
public class AuditService(ILedgerService ledgerService)
{
public async Task RecordAsync(AuditRecord record, CancellationToken ct)
{
var transactionId = await ledgerService.WriteAsync(record, cancellationToken: ct);
var entry = await ledgerService.ReadAsync<AuditRecord>(transactionId, cancellationToken: ct);
Console.WriteLine($"Committed at: {entry?.CommitTimeUtc}");
}
}public record AuditRecord(string UserId, string Action, DateTime Timestamp);
var record = new AuditRecord("user-42", "DocumentSigned", DateTime.UtcNow);
// Write to the default ledger
var transactionId = await ledgerService.WriteAsync(record);// Read with default retry settings (10 attempts, 500ms base delay)
var entry = await ledgerService.ReadAsync<AuditRecord>(transactionId);
if (entry is not null)
{
Console.WriteLine($"Transaction: {entry.TransactionId}");
Console.WriteLine($"Committed at: {entry.CommitTimeUtc}");
Console.WriteLine($"User: {entry.Content.UserId}");
Console.WriteLine($"Action: {entry.Content.Action}");
}const string CollectionId = "audit-2026";
// Write to a specific collection
var transactionId = await ledgerService.WriteAsync(record, CollectionId);
// Read from the same collection
var entry = await ledgerService.ReadAsync<AuditRecord>(
transactionId,
collectionId: CollectionId);Entries can briefly be in a Loading state while the ledger commits and seals them. The reader retries with linear backoff (delayMilliseconds * attempt) until the entry is available or maxRetries is exceeded.
var entry = await ledgerService.ReadAsync<AuditRecord>(
transactionId,
collectionId: null,
maxRetries: 20,
delayMilliseconds: 250,
cancellationToken: ct);If the ledger does not finish loading within the retry budget, a TimeoutException is thrown.
// Bind to a non-default section name
builder.Services.AddBlockchain(builder.Configuration, "MyApp:Ledger");{
"MyApp": {
"Ledger": {
"LedgerEndpoint": "https://my-ledger.confidential-ledger.azure.com"
}
}
}| Setting | Type | Required | Description |
|---|---|---|---|
LedgerEndpoint |
string |
Yes | The Azure Confidential Ledger endpoint URL. |
AzureConfidentialLedgerService uses DefaultAzureCredential, which transparently tries the following credential sources in order:
- Environment variables
- Workload identity (Kubernetes)
- Managed identity
- Visual Studio / Visual Studio Code
- Azure CLI / Azure PowerShell / Azure Developer CLI
- Interactive browser (where enabled)
Ensure the identity running the application has the appropriate role on the ledger resource (typically Confidential Ledger Contributor).
- .NET 8.0
- .NET 9.0
- .NET 10.0
All libraries enable nullable reference types and implicit usings.
This solution uses the modern .slnx (XML-based) solution format.
- .NET 10 SDK or later
- Visual Studio 2022 17.0+ or Visual Studio Code with C# extension
# Clone the repository
git clone https://github.com/nuvtools/nuvtools-blockchain.git
cd nuvtools-blockchain
# Build the solution
dotnet build NuvTools.Blockchain.slnx
# Run tests
dotnet test NuvTools.Blockchain.slnx
# Create NuGet packages
dotnet pack NuvTools.Blockchain.slnx -c ReleaseThe solution structure:
nuvtools-blockchain/
├── src/
│ ├── NuvTools.Blockchain/ # Core abstractions
│ └── NuvTools.Blockchain.Azure/ # Azure Confidential Ledger implementation
├── tests/
│ └── NuvTools.Blockchain.Azure.Test/ # NUnit tests
└── NuvTools.Blockchain.slnx # Solution file
All public APIs include comprehensive XML documentation comments. IntelliSense in Visual Studio, Visual Studio Code, and Rider will display:
- Detailed descriptions of all types, methods, and properties
- Parameter information with expected values
- Return value descriptions
- Exception documentation
- Usage examples and best practices
XML documentation files are included in the NuGet packages for seamless integration.
Licensed under the MIT License.
Copyright © 2026 Nuv Tools