This guide covers the did:cheqd method integration for TrustWeave. The did:cheqd plugin provides Cheqd network DID resolution with payment-enabled features.
Overview
The did/plugins/cheqd module provides an implementation of TrustWeave’s DidMethod interface using the Cheqd network. This integration enables you to:
Create and resolve DIDs on Cheqd blockchain
Store DID documents via blockchain anchoring
Support payment-enabled DID operations
Integrate with Cheqd network’s Cosmos-based infrastructure
Installation
Add the did:cheqd module to your dependencies:
1
2
3
4
5
6
7
8
9
10
dependencies{implementation("com.trustweave.did:cheqd:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-did:1.0.0-SNAPSHOT")implementation("com.trustweave.did:base:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-anchor:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-core:1.0.0-SNAPSHOT")// HTTP client for Cheqd network integrationimplementation("com.squareup.okhttp3:okhttp:4.12.0")}
When the module is on the classpath, did:cheqd is automatically available:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
importcom.trustweave.did.*importcom.trustweave.anchor.*importjava.util.ServiceLoader// Discover did:cheqd providervalproviders=ServiceLoader.load(DidMethodProvider::class.java)valcheqdProvider=providers.find{it.supportedMethods.contains("cheqd")}// Create method with required optionsvaloptions=didCreationOptions{property("cheqdApiUrl","https://api.cheqd.net")property("network","mainnet")property("anchorClient",anchorClient)// Required: provide anchor client}valmethod=cheqdProvider?.create("cheqd",options)
Usage Examples
Creating a did:cheqd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
valconfig=CheqdDidConfig.mainnet("https://api.cheqd.net")valanchorClient=InMemoryBlockchainAnchorClient("cheqd:mainnet")valkms=InMemoryKeyManagementService()valmethod=CheqdDidMethod(kms,anchorClient,config)// Create DID (uses Ed25519 by default)valoptions=didCreationOptions{algorithm=KeyAlgorithm.ED25519purpose(KeyPurpose.AUTHENTICATION)purpose(KeyPurpose.ASSERTION)}valdocument=method.createDid(options)println("Created: ${document.id}")// did:cheqd:mainnet:...
Cheqd is a Cosmos-based blockchain network designed for identity and credentials:
Cosmos-based: Built on Cosmos SDK
Payment-enabled: Supports payment for DID operations
Credential-focused: Designed for verifiable credentials ecosystem
Network Endpoints
Network
API URL
Mainnet
https://api.cheqd.net
Testnet
https://testnet-api.cheqd.net
Blockchain Anchoring
did:cheqd stores DID documents on the Cheqd blockchain using the BlockchainAnchorClient infrastructure. Documents are anchored to the blockchain via transactions, and the transaction hash is used for resolution.
Payment Features
Cheqd network supports payment-enabled DID operations:
importcom.trustweave.TrustWeaveimportcom.trustweave.cheqddid.*importcom.trustweave.anchor.*importcom.trustweave.testkit.anchor.InMemoryBlockchainAnchorClientvalconfig=CheqdDidConfig.mainnet("https://api.cheqd.net")valanchorClient=InMemoryBlockchainAnchorClient("cheqd:mainnet")valTrustWeave=TrustWeave.create{kms=InMemoryKeyManagementService()blockchain{register("cheqd:mainnet",anchorClient)}didMethods{+CheqdDidMethod(kms!!,anchorClient,config)}}// Use did:cheqdvaldid=TrustWeave.createDid("cheqd"){algorithm=KeyAlgorithm.ED25519}.getOrThrow()valresolved=TrustWeave.resolveDid(did.id).getOrThrow()
Payment-Enabled Operations
Cheqd network supports payment for DID operations:
Transaction Fees
DID creation requires transaction fees
DID updates require transaction fees
Fee amount depends on network parameters
Payment Configuration
1
2
3
4
valconfig=CheqdDidConfig.builder().accountAddress("cheqd1...")// Account with funds.privateKey("...")// Private key for signing.build()
Error Handling
Common errors and solutions:
Error
Cause
Solution
cheqdApiUrl not accessible
API endpoint unreachable
Check API URL and network connectivity
Network not supported
Invalid network name
Use mainnet or testnet
BlockchainAnchorClient is required
Missing anchor client
Provide anchor client in options
Failed to anchor document
Transaction failed
Check account balance, gas, network connectivity
DID document not found
Not anchored yet
Anchor document first or check blockchain
Testing
For testing without actual blockchain:
1
2
3
4
5
6
7
8
9
importcom.trustweave.testkit.anchor.InMemoryBlockchainAnchorClientvalconfig=CheqdDidConfig.testnet("https://testnet-api.cheqd.net")valanchorClient=InMemoryBlockchainAnchorClient("cheqd:testnet")valmethod=CheqdDidMethod(kms,anchorClient,config)// Create and resolve (stored in memory)valdocument=method.createDid(options)valresult=method.resolveDid(document.id)
Best Practices
Use testnet for development: Testnet for testing DID operations
Account security: Never hardcode private keys, use environment variables or secure storage
Fee management: Monitor transaction fees and account balance
Network validation: Always validate network matches API endpoint
Error handling: Implement proper error handling for blockchain operations
Use Cases
Payment-Enabled Identity
Cheqd enables payment-enabled identity systems:
1
2
3
4
5
6
// Create DID with paymentvalconfig=CheqdDidConfig.mainnet("https://api.cheqd.net").copy(accountAddress="cheqd1...",privateKey="...")valmethod=CheqdDidMethod(kms,anchorClient,config)valdocument=method.createDid(options)// Requires payment