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;
}