Wallets

Manage Digital Wallet with Wallets Service.

Install Dependency

Package: affinidi-tdk/affinidi-tdk-php

composer require affinidi-tdk/affinidi-tdk-php

You can check the latest version of this module on the Packagist repository or view the source code at the GitHub repository.

Classes and Methods

Wallet API

Used to manage digital wallets for issuing credentials.

createWallet

Create a wallet by type.

Parameters

CreateWalletInput [Object]

JSON object to provide details for the wallet to create. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $request = array( name: "Wallet Name", description: "Description", didMethod: "key" ); $result = $apiInstance->createWallet($request); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

deleteWallet

Delete a Wallet by ID.

Parameters

walletId [String]

ID of the Wallet to delete.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId= "<WALLET_ID-to-delete>"; $result = $apiInstance->deleteWallet($walletId); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

getWallet

Retrieves the details of the Wallet.

Parameters

walletId [String]

ID of the Wallet to retrieve.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId= "<WALLET_ID>"; $result = $apiInstance->getWallet($walletId); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

listWallets

Get the list of the Wallets.

Parameters

No Parameters Required

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $result = $apiInstance->listWallets(); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

signCredential

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

Parameters

walletId [String]

ID of the Wallet used for signing the credential.

SignCredentialInputDto [Object]

JSON object to provide the credential data to sign. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId= "<WALLET_ID>"; $request = array( "unsignedCredential" => array(), "revocable" => true, "unsignedCredentialParams" => array( "jsonLdContextUrl" => "", "jsonSchemaUrl" => "", "typeName" => "", "credentialSubject" => "", "holderDid" => "", "expiresAt" => "" ) ); $result = $apiInstance->signCredential($walletId, $request); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

signJwtToken

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

Parameters

walletId [String]

ID of the Wallet used for signing the JWT.

SignCredentialInputDto [Object]

JSON object to provide the JWT data to sign. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId= "<WALLET_ID>"; $request = array( header: {}, payload: {} ); $result = $apiInstance->signJwtToken($walletId, $request); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

updateWallet

Update an existing Wallet by ID.

Parameters

walletId [String]

ID of the Wallet to update.

UpdateWalletInput [Object]

JSON object to provide details for the wallet to update. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId= "<WALLET_ID>"; $request = array( name: "", description: "" ); $result = $apiInstance->updateWallet($walletId, $request); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

createWalletKey

Add a cryptographic key to an existing wallet.

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

Parameters

walletId [String]

ID of the Wallet to add a key to.

CreateWalletKeyInput [Object]

JSON object to provide the key type and verification relationships. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient; use AffinidiTdk\Clients\WalletsClient\Model\CreateWalletKeyInput; use AffinidiTdk\Clients\WalletsClient\Model\VerificationRelationship;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $input = new CreateWalletKeyInput([ 'key_type' => CreateWalletKeyInput::KEY_TYPE_ED25519, 'relationships' => [ VerificationRelationship::AUTHENTICATION, VerificationRelationship::ASSERTION_METHOD ] ]); $result = $apiInstance->createWalletKey($walletId, $input); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

listWalletKeys

Retrieve all keys associated with a wallet.

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

Parameters

walletId [String]

ID of the Wallet.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $result = $apiInstance->listWalletKeys($walletId); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

removeWalletKey

Remove a key from a wallet.

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

Parameters

walletId [String]

ID of the Wallet.

keyId [String]

Wallet-scoped key identifier.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $keyId = "<KEY_ID>"; $apiInstance->removeWalletKey($walletId, $keyId); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

updateWalletKey

Update the verification relationships of an existing wallet key.

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

Parameters

walletId [String]

ID of the Wallet.

keyId [String]

Wallet-scoped key identifier to update.

UpdateWalletKeyInput [Object]

JSON object to provide the updated verification relationships. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient; use AffinidiTdk\Clients\WalletsClient\Model\UpdateWalletKeyInput; use AffinidiTdk\Clients\WalletsClient\Model\VerificationRelationship;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $keyId = "<KEY_ID>"; $input = new UpdateWalletKeyInput([ 'relationships' => [ VerificationRelationship::AUTHENTICATION, VerificationRelationship::KEY_AGREEMENT ] ]); $result = $apiInstance->updateWalletKey($walletId, $keyId, $input); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

createServiceEndpoint

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

Parameters

walletId [String]

ID of the Wallet.

ServiceEndpointInput [Object]

JSON object to provide the service endpoint details. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient; use AffinidiTdk\Clients\WalletsClient\Model\ServiceEndpointInput;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $input = new ServiceEndpointInput([ 'name' => 'My Service', 'url' => 'https://example.com/service', 'service_type' => 'LinkedDomains' ]); $result = $apiInstance->createServiceEndpoint($walletId, $input); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

listServiceEndpoints

Retrieve all service endpoints associated with a wallet.

Parameters

walletId [String]

ID of the Wallet.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $result = $apiInstance->listServiceEndpoints($walletId); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

removeServiceEndpoint

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

Parameters

walletId [String]

ID of the Wallet.

serviceId [String]

ID of the service endpoint to remove.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $serviceId = "<SERVICE_ID>"; $apiInstance->removeServiceEndpoint($walletId, $serviceId); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }

updateServiceEndpoint

Update an existing service endpoint on a wallet.

Parameters

walletId [String]

ID of the Wallet.

serviceId [String]

ID of the service endpoint to update.

UpdateServiceEndpointInput [Object]

JSON object to provide the updated service endpoint details. See more here.

Example
require_once 'vendor/autoload.php'; use AffinidiTdk\Clients\WalletsClient; use AffinidiTdk\Clients\WalletsClient\Model\UpdateServiceEndpointInput;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken']; // Configure API key authorization: ProjectTokenAuth $config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback); $apiInstance = new WalletsClient\Api\WalletApi( new GuzzleHttp\Client(), $config ); try { $walletId = "<WALLET_ID>"; $serviceId = "<SERVICE_ID>"; $input = new UpdateServiceEndpointInput([ 'url' => 'https://new-endpoint.example.com' ]); $result = $apiInstance->updateServiceEndpoint($walletId, $serviceId, $input); print_r($result); } catch (Exception $e) { echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL; }