The Affinidi TDK for .NET is designed to enable .NET developers to seamlessly integrate Affinidi's services such as Credential Issuance, Credential Verification and Iota Framework for secure data sharing into their applications with minimal effort. Built for developers who value security, privacy and speed, this toolkit simplifies the use of Decentralised Identifiers (DIDs) and Verifiable Credentials (VCs) standards, allowing you to focus on delivering value for users.
With the .NET TDK, you can build secure, consent-driven, and user-centric experiences, from enabling passwordless authentication to issuing or verifying VCs, and implementing VC sharing with user consent at scale.
- Prerequisites
- Requirements
- How do I use Affinidi TDK?
- Installation
- Quickstart
- Documentation
- Support & Feedback
- Contributing
- FAQ
- Telemetry
Before getting started, ensure you have:
- An Affinidi Portal Account
- A Personal Access Token (PAT) - Learn how to create one
- .NET 8 SDK (minimum version:
8.0.400)
You can check your installed version using:
dotnet --versionThe Affinidi TDK provides two types of modules:
- Clients: offer methods to access Affinidi Elements services like Credential Issuance, Credential Verification, and Login Configurations, among others.
- Packages: are commonly used utilities/helpers that are self-contained and composable.
Note: These are optional if you have already created a project.
- Create a project directory:
mkdir my-dotnet-app - Create the project:
dotnet create console
Note: The Affinidi TDK clients use authorisation token to authenticate client requests. You can generate a token with the use of the AuthProvider package.
To install TDK client or package in dotnet, you need to run the command below:
dotnet add package <Affinidi-Package-Name>
Example (installing the AffinidiTdk.AuthProvider Package):
dotnet add package AffinidiTdk.AuthProvider
All Affinidi TDK Clients and Packages are available in nuget.org.
Here's a basic example of using the .NET TDK to create a wallet for signing verifiable credentials using the WalletApi from AffinidiTdk.WalletsClient:
using DotNetEnv;
using AffinidiTdk.AuthProvider;
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;
public class CreateWalletExample
{
static async Task Main(string[] args)
{
// Use DotEnv to load environment variables
// Ensure that you have a .env in place with the values before proceeding
Env.Load();
// Instantiate AuthProviderConfig object to load the AuthProvider.
// Never hardcode sensitive values in production
// Use environment variables or secure configuration management
var authProviderParams = new AuthProviderParams
{
// Please generate your own Personal Access Tokens (PAT).
// Refer to https://docs.affinidi.com/dev-tools/affinidi-tdk/get-access-token/#create-a-personal-access-token-pat for the guide on creating your own PAT.
ProjectId = Environment.GetEnvironmentVariable("PROJECT_ID"),
TokenId = Environment.GetEnvironmentVariable("TOKEN_ID"),
PrivateKey = Environment.GetEnvironmentVariable("PRIVATE_KEY")
};
// create an AuthProvider instance
AuthProvider authProvider = new AuthProvider(authProviderParams);
// fetch the projectScopedToken from the authProviderConfig
string projectScopedToken = await authProvider.FetchProjectScopedTokenAsync();
// create an instance of Configuration from AffinidiTdk.CredentialIssuanceClient
Configuration config = new Configuration();
// set the projectScopedToken as apiKey. Note that its using a Map/Dictionary. Key here is "authorization"
config.AddApiKey("authorization", projectScopedToken);
// create an instance of WalletApi (from using AffinidiTdk.WalletsClient.Api) and pass the config in the constructor argument.
WalletApi api = new WalletApi(config);
// create a CreateWalletInput object with the name and did method
CreateWalletInput input = new CreateWalletInput(name: "DotNet Wallet", didMethod: CreateWalletInput.DidMethodEnum.Key);
try
{
// call the CreateWallet api and pass the CreateWalletInput as argument
CreateWalletResponse result = api.CreateWallet(input);
Console.WriteLine("CreateWallet Result: " + result.ToJson());
}
catch (Exception ex)
{
Console.WriteLine($"Error creating wallet: {ex.Message}");
}
}
}Running the code will display the result similar to below:
CreateWallet Result: {
"wallet": {
"id": "<WALLET-ID>",
"did": "<WALLET-DID>",
"name": "DotNet Wallet",
...
}
}
We've provided a feature to manage your project access token lifecycle by automatically refreshing it, ensuring the client APIs always use a valid, up-to-date token. Refer to the example code.
Head over to our Documentation site to know how to get started with Affinidi TDK.
Use this document to learn more about how to work with Affinidi TDK, including generating the Authorisation Token and calling the methods.
To learn how to integrate Affinidi TDK and use the different modules into your application, you can explore the following:
If you face any issues or have suggestions, please don't hesitate to contact us using this link.
If you have a technical issue with the Affinidi TDK's codebase, you can also create an issue directly in GitHub.
-
Ensure the bug was not already reported by searching on GitHub under Issues.
-
If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
We enjoy community contributions! Whether it’s bug fixes, feature requests, or improving docs, your input helps shape the Affinidi TDK.
- Head over to our CONTRIBUTING to get started.
- Have an idea? Start a discussion in GitHub Discussions or Discord
You are only limited by your imagination! Affinidi TDK is a toolbox with which you can build software applications for personal or commercial use.
We only provide the tools - how you use them is largely up to you. We have no control over what you develop with our tools - but please use our tools responsibly!
We hope that you will not develop anything that contravenes any applicable laws or regulations. Your projects should also not infringe on Affinidi's or any third party's intellectual property (for instance, misusing other parties' data, code, logos, etc).
Please ensure that you have in place your terms and conditions, privacy policies, and other safeguards to ensure that the projects you build are secure for your end users.
If you are processing personal data, please protect the privacy and other legal rights of your end-users and store their personal or sensitive information securely.
Some of our components would also require you to incorporate our end-user notices into your terms and conditions.
Affinidi TDK itself is free, so come onboard and experiment with our tools and see what you can build! We may bill for certain components in the future, but we will inform you beforehand.
We may from time to time impose limits on your use of the Affinidi TDK, such as limiting the number of API requests that you may make in a given duration. This is to ensure the smooth operation of the Affinidi TDK so that you and all our other users can have a pleasant experience as we continue to scale and improve the Affinidi TDK.
From time to time, we may request certain information from you to ensure that you are complying with the Terms and Conditions.
When you create a developer's account with us, we will issue you your private login credentials. Please do not share this with anyone else, as you would be responsible for activities that happen under your account. If you have interested friends, ask them to sign up – let's build together!
Affinidi collects usage data to improve our products and services. For information on what data we collect and how we use your data, please refer to our Privacy Notice.
Disclaimer: Please note that this FAQ is provided for informational purposes only and is not to be considered a legal document. For the legal terms and conditions governing your use of the Affinidi Services, please refer to our Terms and Conditions.