# Wallets

> Manage Digital Wallet with Wallets Service.

## Install Dependency

Package: AffinidiTdk.WalletsClient

```bash
dotnet add package AffinidiTdk.WalletsClient
```

Check the latest version on [nuget.org](https://www.nuget.org/packages/AffinidiTdk.WalletsClient) or view the source on [GitHub](https://github.com/affinidi/affinidi-tdk-dotnet/tree/main/src/Clients/WalletsClient).

## Classes and Methods

### Wallet API

Used to manage digital wallets for issuing credentials.

#### CreateWallet

Create a wallet by type.

Parameters

    CreateWalletInput
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/CreateWalletInput.md)
    Required
  JSON object to provide details for the wallet to create.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

CreateWalletInput input = new CreateWalletInput(name: "DotNet Wallet", didMethod: CreateWalletInput.DidMethodEnum.Key);

CreateWalletResponse result  = api.CreateWallet(input);
```

#### DeleteWallet

Delete a Wallet by ID.

Parameters

    walletId
    String
    Required
  ID of the Wallet to delete.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();

config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";

api.DeleteWallet(walletId);
```

#### GetWallet

Retrieves the details of the Wallet.

Parameters

    walletId
    String
    Required
  ID of the Wallet to retrieve.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();

config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";

WalletDto result = api.GetWallet(walletId);
```

#### ListWallets

Get the list of the Wallets.

No parameters required.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();

config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

WalletsListDto result = api.ListWallets();
```

#### SignCredential

Sign a credentials with the Wallet details (DID document).

Parameters

    walletId
    String
    Required
  ID of the Wallet used for signing the credential.

    SignCredentialInputDto
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/SignCredentialInputDto.md)
    Required
  JSON object to provide the credential data to sign.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();

config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
SignCredentialInputDto input = new SignCredentialInputDto();

SignCredentialResultDto result = api.SignCredential(walletId, input);
```

#### SignJwtToken

Sign the JSON Web Token with the Wallet details (DID document).

Parameters

    walletId
    String
    Required
  ID of the Wallet used for signing the JWT.

    SignCredentialInputDto
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/SignJwtToken.md)
    Required
  JSON object to provide the JWT data to sign.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();

config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
SignJwtToken input = new SignJwtToken();

SignJwtTokenOK result = api.SignJwtToken(walletId, input);
```

#### UpdateWallet

Update an existing Wallet by ID.

Parameters

    walletId
    String
    Required
  ID of the Wallet to update.

    UpdateWalletInput
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/UpdateWalletInput.md)
    Required
  JSON object to provide details for the wallet to update.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
UpdateWalletInput input = new UpdateWalletInput();

WalletDto result  = api.UpdateWallet(walletId, input);
```

#### CreateWalletKey

Add a cryptographic key to an existing wallet.

Note: Multiple keys are only supported for did:web wallets.

Parameters

    walletId
    String
    Required
  ID of the Wallet to add a key to.

    CreateWalletKeyInput
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/CreateWalletKeyInput.md)
    Required
  JSON object to provide the key type and verification relationships.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";

CreateWalletKeyInput input = new CreateWalletKeyInput
{
    KeyType = "ed25519",
    Relationships = new List
    {
        VerificationRelationship.Authentication,
        VerificationRelationship.AssertionMethod
    }
};

WalletKeyDto result = api.CreateWalletKey(walletId, input);
```

{
KeyType = “ed25519”,
Relationships = new List
{
VerificationRelationship.Authentication,
VerificationRelationship.AssertionMethod
}
};

WalletKeyDto result = api.CreateWalletKey(walletId, input);

```
---

#### ListWalletKeys

Retrieve all keys associated with a wallet.

> **Note:** Multiple keys are only supported for `did:web` wallets.

**Parameters**

    walletId
    String
    Required
  ID of the Wallet.

**Example**

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";

ListWalletKeysOK result = api.ListWalletKeys(walletId);
```

#### RemoveWalletKey

Remove a key from a wallet.

Note: Multiple keys are only supported for did:web wallets.

Parameters

    walletId
    String
    Required
  ID of the Wallet.

    keyId
    String
    Required
  Wallet-scoped key identifier.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
var keyId = "";

api.RemoveWalletKey(walletId, keyId);
```

#### UpdateWalletKey

Update the verification relationships of an existing wallet key.

Note: Multiple keys are only supported for did:web wallets.

Parameters

    walletId
    String
    Required
  ID of the Wallet.

    keyId
    String
    Required
  Wallet-scoped key identifier to update.

    UpdateWalletKeyInput
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/UpdateWalletKeyInput.md)
    Required
  JSON object to provide the updated verification relationships.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
var keyId = "";

UpdateWalletKeyInput input = new UpdateWalletKeyInput
{
    Relationships = new List
    {
        VerificationRelationship.Authentication,
        VerificationRelationship.KeyAgreement
    }
};

WalletKeyDto result = api.UpdateWalletKey(walletId, keyId, input);
```

#### CreateServiceEndpoint

Add a DID service endpoint to a wallet’s DID document.

Parameters

    walletId
    String
    Required
  ID of the Wallet.

    ServiceEndpointInput
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/ServiceEndpointInput.md)
    Required
  JSON object to provide the service endpoint details.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";

ServiceEndpointInput input = new ServiceEndpointInput
{
    Name = "My Service",
    Url = "https://example.com/service",
    ServiceType = "LinkedDomains"
};

ServiceEndpointDto result = api.CreateServiceEndpoint(walletId, input);
```

#### ListServiceEndpoints

Retrieve all service endpoints associated with a wallet.

Parameters

    walletId
    String
    Required
  ID of the Wallet.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";

ListServiceEndpointsOK result = api.ListServiceEndpoints(walletId);
```

#### RemoveServiceEndpoint

Remove a service endpoint from a wallet’s DID document.

Parameters

    walletId
    String
    Required
  ID of the Wallet.

    serviceId
    String
    Required
  ID of the service endpoint to remove.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
var serviceId = "";

api.RemoveServiceEndpoint(walletId, serviceId);
```

#### UpdateServiceEndpoint

Update an existing service endpoint on a wallet.

Parameters

    walletId
    String
    Required
  ID of the Wallet.

    serviceId
    String
    Required
  ID of the service endpoint to update.

    UpdateServiceEndpointInput
    [Object](https://github.com/affinidi/affinidi-tdk-dotnet/blob/main/src/Clients/WalletsClient/docs/UpdateServiceEndpointInput.md)
    Required
  JSON object to provide the updated service endpoint details.

Example

```cs
using AffinidiTdk.WalletsClient.Client;
using AffinidiTdk.WalletsClient.Api;
using AffinidiTdk.WalletsClient.Model;

Configuration config = new Configuration();
config.AddApiKey("authorization", projectScopedToken);

WalletApi api = new WalletApi(config);

var walletId = "";
var serviceId = "";

UpdateServiceEndpointInput input = new UpdateServiceEndpointInput
{
    Url = "https://new-endpoint.example.com"
};

ServiceEndpointDto result = api.UpdateServiceEndpoint(walletId, serviceId, input);
```
