Skip to content

Usage examples

Essbante edited this page May 26, 2022 · 4 revisions

Example #1 - Create issuer and holder wallets

Create a wallet for the issuer using the following command:

$ ./wal.sh new-wallet issuer_wallet

issuer_wallet is an arbitrary name. You can change it.

Expected response:

-- new-wallet --
wallet created

Then create a wallet for the holder. In this case, provide the mnemonic phrase using the option -m.

$ ./wal.sh new-wallet holder_wallet -m poet,account,require,learn,misery,monitor,medal,great,blossom,steak,rain,crisp

holder_wallet is an arbitrary name; you can change it. The mnemonic is not random; use a valid one.

Expected response:

-- new-wallet --
wallet created

You may have noticed both wallets exist on the same WAL instance, and this is because WAL is multitenant.

Example #2 - Create issuer and holder DIDs and publish the issuer DID

To create the holder DID use the command:

$ ./wal.sh new-did holder_wallet holder_did

The holder DID is created within the holder_wallet, the value holder_did is an arbitrary alias.

Expected response:

-- new-did --
DID created

To create an issuer DID, add the -i option to the command; this will add issuing and revocation keys to the DID document. When the -i option is not used, only the master key is included.

$ ./wal.sh new-did issuer_wallet issuer_did -i

The issuer DID is created within the issuer_wallet, the value issuer_did is an arbitrary alias.

Expected response:

-- new-did --
DID created

Publish the issuer DID using the command:

$ ./wal.sh publish-did issuer_wallet issuer_did

Expected response:

Current operation status: PENDING_SUBMISSION

Track the transaction in:
- https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=7d96807bcf6e32cd7831636f1330bea1f47f44a5fd00742be0a571ce5d1c9979

Current operation status: AWAIT_CONFIRMATION

Current operation status: AWAIT_CONFIRMATION

...

Current operation status: AWAIT_CONFIRMATION

-- publish-did --
DID published

Example #3 - Issue and verify a credential

To issue a credential is required to know the holder did:prism long-form, use the command below to display the DID data:

$ ./wal.sh show-did-data holder_wallet holder_did

Expected response:

-- show-did-data --
{
    "alias": "holder_did",
    "didIdx": 0,
    "uriCanonical": "did:prism:654a4a9113e7625087fd0d3143fcac05ba34013c55e1be12daadd2d5210adc4d",
    "uriLongForm": "did:prism:654a4a9113e7625087fd0d3143fcac05ba34013c55e1be12daadd2d5210adc4d:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VjcDI1NmsxEiEDA7B2nZ_CvcIdkU2ovzBEovGzjwZECMUeHUeNo5_0Jug",
    "operationHash": "",
    "keyPairs": [
        {
            "keyId": "master0",
            "didIdx": 0,
            "keyType": 0,
            "keyIdx": 0,
            "privateKey": "9c2a64d860cb86ce0af23787fccd2ad12a73d5e758c706d8567de49dec2ec029",
            "publicKey": "0403b0769d9fc2bdc21d914da8bf3044a2f1b38f064408c51e1d478da39ff426e884c34858bcfa2afbd3cc4e4b1a8d3fc848b74f92360e91729aaf8d77d8207963",
            "revoked": false
        }
    ]
}

Copy the uriLongForm value and use it in the command issue-cred:

$ ./wal.sh issue-cred issuer_wallet issuer_did did:prism:654a4a9113e7625087fd0d3143fcac05ba34013c55e1be12daadd2d5210adc4d:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VjcDI1NmsxEiEDA7B2nZ_CvcIdkU2ovzBEovGzjwZECMUeHUeNo5_0Jug credential_a

The credential is issued by the issuer_wallet, under the issuer_did signature. The value credential_a is an arbitrary alias. In this example, the content of the credential is a randomized value. Using the option -j, you can provide a custom JSON file with credential content.

Expected Response:

Current operation status: PENDING_SUBMISSION

Current operation status: PENDING_SUBMISSION

Current operation status: PENDING_SUBMISSION

Track the transaction in:
- https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=84c0c95e3e687b6276bc3c620abb66d767f08af10e00331ebf3740347679d82f

Current operation status: AWAIT_CONFIRMATION

Current operation status: AWAIT_CONFIRMATION

...

Current operation status: AWAIT_CONFIRMATION

-- issue-cred --
Credential issued

To verify the credential, use the command:

$ ./wal.sh verify-cred issuer_wallet issued credential_a

WAL wallets have two sets of credential collections, one is for credentials issued by the wallet, and the other is for imported credentials. The parameter issued is used to indicate where to find the credential to be verified.

Expected response:

-- verify-cred --
Valid credential.

Example #4 - Export a credential

Export the credential using the command:

$ ./wal.sh export-cred issuer_wallet credential_a credential_a.json

You can only export credentials from the issued collection. _ credential_a.json_ is the output filename.

Expected response:

-- export-cred --
Credential exported

Example #5 - Import a credential and verify it

Import the credential using the command:

$ ./wal.sh import-cred holder_wallet credential_a credential_a.json

Again credential_a is an arbitrary name, credential_a.json is the input filename.

Expected response:

-- import-cred --
Credential imported

Verify the imported credential with the command:

$ ./wal.sh verify-cred holder_wallet imported credential_a

The argument imported indicates the credential's collection, since this is an imported credential use imported instead of issued.

Expected response:

-- verify-cred --
Valid credential.

Example #6 - Revoke a credential

From the issuer wallet, revoke the credential with the command:

$ ./wal.sh revoke-cred issuer_wallet credential_a

Expected response:

Current operation status: PENDING_SUBMISSION

Track the transaction in:
- https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=0915eacc03f9f366ca9505a6615e6876a7936775ece416c43aa4cb08f4a100fe

Current operation status: AWAIT_CONFIRMATION

Current operation status: AWAIT_CONFIRMATION

...

Current operation status: AWAIT_CONFIRMATION

-- revoke-cred --
Credential revoked

Verify the credential from the holder and issuer wallet. In both cases, it will say the credential is invalid.

$ ./wal.sh verify-cred holder_wallet imported credential_a

Expected response:

-- verify-cred --
Invalid credential.

$ ./wal.sh verify-cred issuer_wallet issued credential_a

Expected response:

-- verify-cred --
Invalid credential.