Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cheqd): Add Cheqd create resource tutorial #171

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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