🖼️Resource Module - Manage DID-Linked Resources
The DID-Linked Resource module provides comprehensive functionality for managing DID-Linked Resources on the cheqd network. This module enables you to create, version, and manage immutable resources that are cryptographically linked to DIDs, supporting various data types like schemas, credential definitions, status lists, and custom artifacts.
Summary
DID-Linked Resources are immutable data objects that can be linked to DIDs, providing a secure and verifiable way to associate additional data with Decentralized Identifiers. The cheqd DID-Linked Resource module supports comprehensive resource lifecycle management with the following capabilities:
Key Features
Immutable Storage: Resources are permanently stored and cannot be modified after creation
Version Management: Create new versions of resources with automatic double-linked list versioning
Multiple Resource Types: Support for schemas, credential definitions, status lists, and custom types
Cryptographic Linking: Resources are cryptographically linked to DIDs for authenticity
Content Addressing: Unique resource identification using checksums and metadata
Fee Abstraction: Pay fees using IBC tokens (USDC, EURe, OSMO) or native CHEQ tokens
Supported Operations
The DID-Linked Resource module supports two main operation categories:
Resource Creation: Create new immutable resources linked to DIDs
Resource Management: Create new versions of existing resources (versioning system)
Quick Start Guides
Resource Operations Reference
Creation Operations
Create Resource
createLinkedResourceTx()
Create a new DID-Linked Resource
signInputs
, resourcePayload
, feePayer
fee
, memo
Management Operations
Create Version
createLinkedResourceTx()
Create new version of existing resource
signInputs
, resourcePayload
, feePayer
fee
, memo
Resource Types and Use Cases
Supported Resource Types
CL-Schema
Camenisch-Lysyanskaya Schema
AnonCreds credential schemas
JSON schema definition
CL-CredDef
Credential Definition
AnonCreds credential definitions
JSON credential definition
Bitstring Status List
Revocation Status List
Credential revocation/suspension tracking
Compressed bitstring
JSONSchema
JSON Schema
W3C VC JSON Schema validation
JSON schema specification
custom
Custom Resource Type
Application-specific data
Any format (JSON, text, binary)
Resource Metadata
Each DID-Linked Resource includes comprehensive metadata:
collectionId
string
DID that owns the resource
✅
id
string
Unique resource identifier (UUID)
✅
name
string
Human-readable resource name
✅
resourceType
string
Type of resource (schema, credDef, etc.)
✅
mediaType
string
MIME type of resource content
✅
checksum
string
SHA-256 hash of resource content
✅
created
string
ISO 8601 creation timestamp
✅
version
string
Resource version identifier
❌
alsoKnownAs
array
Alternative resource identifiers
❌
nextVersionId
string
Next version in the chain
❌
previousVersionId
string
Previous version in the chain
❌
Versioning and Immutability
Version Chain Management
DID-Linked Resources use a double-linked list structure for versioning:
Version 1 ←→ Version 2 ←→ Version 3
↑ ↑ ↑
oldest intermediate newest
Key Versioning Rules
Same Name + Type = New Version: Resources with identical
name
andresourceType
create version chainsAutomatic Linking: New versions automatically link to previous versions
Immutable History: All versions remain permanently accessible
Content Independence: Versions can have identical or different content
Fee Structure and Payment Options
Fee Payment Methods
Native Fees
CHEQ
Standard network fees
Fee Abstraction
USDC, EURe, OSMO
IBC token fee payment
Resource Creation Costs
Resource creation fees are based on:
Base transaction fee (network operation)
Storage fee (proportional to resource size)
Additional validation costs (for complex resource types)
Integration Patterns
Common Workflows
Schema Publishing
Publish credential schemas for verifiers
Create CL-Schema or JSONSchema resources
Credential Definition
Define credential parameters for issuers
Create CL-CredDef resources linked to schemas
Status List Management
Track credential revocation status
Create and version StatusList2021 resources
Custom Data Storage
Store application-specific data
Create custom resource types with arbitrary content
Best Practices
Resource Planning: Design resource naming and versioning strategy before creation
Content Validation: Validate resource content before creation (immutable after creation)
Version Management: Use descriptive version identifiers for easier tracking
Fee Optimization: Choose appropriate token types based on cost and availability
Access Patterns: Consider how applications will discover and retrieve resources
Error Handling
Common Error Scenarios
Invalid DID
Collection ID doesn't exist or is deactivated
Verify DID exists and is active
Insufficient Fees
Transaction fee too low
Increase fee amount or check fee calculation
Invalid Content
Resource content doesn't match type requirements
Validate content format before creation
Authorization Failed
Signing key not authorized for DID
Use authorized verification method
Network Issues
Connection or network problems
Retry with exponential backoff
Error Response Format
interface ResourceError {
code: number;
message: string;
details?: {
resource?: string;
collection?: string;
validation?: string[];
};
}
Advanced Usage Examples
Programmatic Resource Discovery
// Query resources by collection (DID)
const resources = await sdk.querier.cheqd.resource.v2.collectionResources({
collectionId: "did:cheqd:mainnet:example123"
});
// Query specific resource with metadata
const resource = await sdk.querier.cheqd.resource.v2.resource({
collectionId: "did:cheqd:mainnet:example123",
id: "resource-uuid-here"
});
// Query resource version chain
const versionChain = await sdk.querier.cheqd.resource.v2.resourceVersions({
collectionId: "did:cheqd:mainnet:example123",
name: "CredentialSchema",
resourceType: "CL-Schema"
});
Resource Content Retrieval
// Fetch resource content by ID
const content = await fetch(
`https://resolver.cheqd.net/1.0/identifiers/${collectionId}/resources/${resourceId}`
);
// Fetch latest version by name and type
const latestContent = await fetch(
`https://resolver.cheqd.net/1.0/identifiers/${collectionId}/resources/${name}?resourceType=${type}`
);
Migration and Compatibility
SDK Version Compatibility
v3.0+
Full versioning support, fee abstraction
Updated method signatures
v2.x
Basic resource creation
Limited versioning
v1.x
Legacy resource format
Not recommended
Migration Guidelines
When upgrading from older SDK versions:
Update Dependencies: Upgrade to latest SDK version
Review Method Signatures: Check for parameter changes
Test Resource Creation: Validate new version behavior
Update Fee Handling: Implement fee abstraction if needed
Security Considerations
Resource Security Best Practices
Content Validation: Always validate resource content before creation
Key Management: Secure storage of DID authentication keys
Access Control: Implement proper authorization checks
Content Verification: Verify resource checksums after retrieval
Network Security: Use HTTPS endpoints for resource access
Privacy Considerations
Public Storage: All resources are publicly accessible
Content Sensitivity: Avoid storing sensitive personal data
Metadata Privacy: Resource names and types are public
Version History: All versions remain permanently visible
Troubleshooting
Common Issues
Resource Not Found
404 errors when accessing resources
Verify collection ID and resource ID
Version Chain Broken
Missing version links
Check version creation order
Fee Calculation Errors
Transaction rejected due to insufficient fees
Use dynamic fee calculation
Content Type Mismatch
Resource rejected during creation
Ensure content matches declared mediaType
Authorization Errors
Transaction fails with authorization error
Verify signing key is authorized for DID
Debug Information
For debugging resource operations:
Check Network Status: Verify network connectivity and status
Validate Input Parameters: Ensure all required parameters are provided
Review Transaction Logs: Check transaction hash and block explorer
Verify DID Status: Confirm the associated DID is active
Check Resource Limits: Verify resource size is within network limits
Related Documentation
SDK Setup and Configuration
SDK Setup Guide - Initial SDK configuration
Fee Abstraction Guide - IBC token fee payment
DID Management
DID Module Overview - DID lifecycle management
Create DID Guide - DID creation procedures
Network and Tools
Network Overview - cheqd network information
Block Explorer - Transaction monitoring
Last updated
Was this helpful?