Adding a new Resource version
The purpose of this document is to describe how someone can create a new Resource on under an existing Collection.
This tutorial uses the cheqd Cosmos CLI, similar to the creating a new Resource tutorial.
Pre-requisites
Install the latest stable cheqd-node CLI, either as a standalone binary or Docker container image.
Acquire test CHEQ tokens through our testnet faucet (if creating it on our testnet), or CHEQ tokens (if you plan on creating it on mainnet).
Having a Resource already created under this DIDDoc Collection
Adding a new Resource to an existing DIDDoc Collection
1. Generate a new UUID for the new Resource version
UUIDs are used to identify Resources. On Unix systems, the uuidgen
tool can be used to generate a new UUID:
2. Prepare a file with Resource content
Resource content should be placed in a file and stored locally.
3. Publish the new Resource version to the ledger
Resources with the same Collection ID and name are grouped into version sets. Each resource in such a set has a link to the previous version (except the first version) and the next version (if it's not the most recent version).
To create a resource and mark it as a new version within a particular group, we need to use the same collection-id
and name
as in the previous version. Links between versions will be created automatically.
New versions have dedicated unique IDs and can be referenced and retrieved as any other resources.
Command
Parameters
payload-file
- file with JSON formatted payload. The format and structure can be found in exampleresource-data-file
- file which will be sent to the ledger as adata
. Can be a picture or an image or whatever you want.flags
- additional parameters like,--gas
or--from
.--fees
should match the price of the speicfic resource file type defined here.
Example
where payload.json
is:
After you execute the command, you will receive "code": 0"
if the resource was successfully written to the ledger.
Otherwise, the raw_logs
field in the response can help figure out why something went wrong. For example:
4. Check that new Resource version was successfully written to the ledger
Finally, to check that the resource was successfully written, we can use the following query:
Parameters
<collection-id>
: The same unique identifier as that after the namespace of the corresponding DID created in step 1<resource-id>
: Unique ID of the resource within the collection of resources associated with the DIDDoc
Example
Result
Notice that previous_version_id
is not empty and pointing to the previously created resource with id
: 3e6bd814-6851-4c8a-b114-c64f035ef590
.
Last updated