Create a DID-Linked Resource
Follow these instructions to create a new DID-Linked Resource on cheqd mainnet or testnet.
⚠️ Before you begin...
Make sure you've correctly configured the cheqd plugin's agent settings for Veramo CLI
Instructions
1. Create a DID
Follow this tutorial to generate keys and create a DID.
2. Create your Resource content and save the file locally
DID-Linked Resources can be any type of file or content that is below ~200kb in size.
For the purpose of an example, lets use an AnonCreds schema (JSON file) as the resource:
Save this file locally and call it something like resource.json.
3. Create a UUID for the Resource
UUIDs are used to identify DID-Linked Resources. On Unix systems, the uuidgen
tool can be used to generate a new UUID:
4. Choose an option for passing the resource that best suits you
Option 1: Passing resource as Base64
Prepare a file with resource and encode it into base64
. On Unix systems, you can use the following command input:
Expected output:
You will need to paste the output of the Base64 into the data
field of the payload.json
file as shown in step 5.
Option 2: Passing resource as file
Once you have saved your Resource file locally, you can copy the path and enter it in the file
field of the payload.json
file as shown in step 5.
5. Prepare your payload file
Before carrying out a Resource transaction, you will need to prepare the payload.json
file. This file can be saved wherever you choose, but the location must be specified in the create Resource command. (By default, it will be saved under the project root directory.)
Parameters
kms
(defaultlocal
): Key Management System (KMS) to be used for storage;payload
: Resource definitioncollectionId
: The last fragment of the corresponding DIDDocid
: Use output from the previous step herename
: Arbitrary human-readable string used to identify the resourceresourceType
: Resource type, such asCL-Schema
,JSONSchema2020
, etcversion
: (Optional) client-given resource versionalsoKnownAs
: (Optional) alternative URI(s) provided for the resourcedata
: (Optional) base64 encoded data of resource file
signInputs
: Keys used to sign the corresponding DIDDoc. These must match the ones specified in the DIDDoc, otherwise an error will be thrownverificationMethodId
: Verification method ID from DIDDoc where key is publishedkeyType
should match values that you used to create the DIDDocprivateKeyHex
should match values that you used to create the DIDDoc
file
: (Optional) path to resource filefee:
amount
: An array of coins, coins are represented as an object with 2 fieldsdenom
: ncheq (smallest denomination classification)amount
: See section below on fees
gas
: Each transaction must specify the maximum amount of gas it may consume.payer
(Optional): The cheqd fee payer addressgranter
(Optional): The cheqd fee granter address, Provided the grantee has an allowance by the granter
The Payload file can include a Resource passed either as a file or a base64 encoded string:
6. Understanding Resource Fees
The maximum file size for a resource is roughly 46KB which may require a gas fee of up to 2000000.
The fee for a resource transaction changes depending on the file type being passed to the ledger. Currently there are three different variations on the fee:
Note that transaction fees are paid by the cheqd account set in the
agent.yml
configuration file, setup here. If you do not specify a fee in the transaction, the ledger will automatically deduct the appropriate fee from the account set in youragent.yml
configuration. Each of cheqd's on-ledger identity transactions has a fixed fee, the pricing for cheqd DIDs and DID-Linked Resources can be found here. If your account has insufficient balance the transaction will fail.
7. Create new DID-Linked Resource
If you do not specify the --argsFile
in the previous step, you can also paste a JSON inline argument object by using the --argsJSON
flag followed by the JSON payload.
Last updated