Skip to content

Commit

Permalink
docs(cheqd): Add Cheqd create resource tutorial (#171)
Browse files Browse the repository at this point in the history
Signed-off-by: DaevMithran <daevmithran1999@gmail.com>
  • Loading branch information
DaevMithran committed Sep 13, 2024
1 parent 71899a3 commit 4fd67c1
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 149 deletions.
47 changes: 47 additions & 0 deletions guides/tutorials/cheqd/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,53 @@ A DID can be deactivated, it can still be resolved

```

### Create Resource

Using the createResource cheqd api agents are able to create custom DID-Linked Resources, including:

- Trust Registries
- Status Lists
- Logos associated with DIDs
- Governance files

#### Parameters

1. `did`\*
2. `name`\*
3. `resourceType`\*
4. `id`\*
5. `data`\* : Text, Base64 string or an object
6. `alsoKnownAs`
7. `version`

```typescript showLineNumbers set-up-cheqd.ts section-6

```

### Resolve Resource

The resolveResource function in the cheqd API allows agents to resolve DID-Linked Resources in two ways:

- By `resourceId`
- By `resourceName` and `resourceType`

Additionally, both conventions support the following query parameters:

- To fetch a specific resource version: `resourceUrl?version=<versionId>`
- To fetch the closest resource version for a given time: `resourceUrl?resourceVersionTime=<epoch time>`

#### Using `resourceId`

```typescript showLineNumbers set-up-cheqd.ts section-7

```

#### Using `resourceName` and `resourceType`

```typescript showLineNumbers set-up-cheqd.ts section-8

```

### Types

---
Expand Down
16 changes: 8 additions & 8 deletions snippets/current/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"dev:set-up": "ts-node --esm src/set-up.ts"
},
"dependencies": {
"@credo-ts/anoncreds": "^0.5.3",
"@credo-ts/askar": "^0.5.3",
"@credo-ts/cheqd": "^0.5.3",
"@credo-ts/core": "^0.5.3",
"@credo-ts/indy-vdr": "^0.5.3",
"@credo-ts/node": "^0.5.3",
"@credo-ts/openid4vc": "^0.5.3",
"@credo-ts/react-native": "^0.5.3",
"@credo-ts/anoncreds": "^0.5.11-alpha-20240827114018",
"@credo-ts/askar": "^0.5.11-alpha-20240827114018",
"@credo-ts/cheqd": "^0.5.11-alpha-20240827114018",
"@credo-ts/core": "^0.5.11-alpha-20240827114018",
"@credo-ts/indy-vdr": "^0.5.11-alpha-20240827114018",
"@credo-ts/node": "^0.5.11-alpha-20240827114018",
"@credo-ts/openid4vc": "^0.5.11-alpha-20240827114018",
"@credo-ts/react-native": "^0.5.11-alpha-20240827114018",
"@hyperledger/anoncreds-nodejs": "^0.2.1",
"@hyperledger/anoncreds-react-native": "^0.2.1",
"@hyperledger/anoncreds-shared": "^0.2.1",
Expand Down
25 changes: 25 additions & 0 deletions snippets/current/src/set-up-cheqd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,28 @@ await agent.dids.deactivate({
},
})
// end-section-5

// start-section-6
await agent.modules.cheqd.createResource('did:cheqd:testnet:92874297-d824-40ea-8ae5-364a1ec9237d', {
name: 'resourceName',
resourceType: 'resourceType',
id: '6de33634-6439-4e46-aa3f-bfe03606b000',
version: '1.0',
data: {
name: 'name',
age: 18,
},
})
// end-section-6

// start-section-7
await agent.modules.cheqd.resolveResource(
'did:cheqd:testnet:92874297-d824-40ea-8ae5-364a1ec9237d/resources/6de33634-6439-4e46-aa3f-bfe03606b000'
)
// end-section-7

// start-section-8
await agent.modules.cheqd.resolveResource(
'did:cheqd:testnet:92874297-d824-40ea-8ae5-364a1ec9237d?resourceName=resourceName&resourceType=resourceType'
)
// end-section-8
Loading

0 comments on commit 4fd67c1

Please sign in to comment.