When using cheqd method with Credo, there are a few extra dependencies that need to be installed. We need to install the @credo-ts/cheqd package, which implements the needed interfaces for the agent.
After installing the dependencies, we can register the cheqd module on the agent by adding the below code snippet to the agent constructor.
import { Agent, DidsModule, KeyType, DidDocument } from '@credo-ts/core'
import { agentDependencies } from '@credo-ts/node'
import { AskarModule } from '@credo-ts/askar'
import { askar } from '@openwallet-foundation/askar-nodejs'
import {
ConnectionsModule,
V2ProofProtocol,
V2CredentialProtocol,
ProofsModule,
AutoAcceptProof,
AutoAcceptCredential,
CredentialsModule,
HttpOutboundTransport,
getDefaultDidcommModules,
} from '@credo-ts/didcomm'
import {
CheqdAnonCredsRegistry,
CheqdDidRegistrar,
CheqdDidResolver,
CheqdModule,
CheqdModuleConfig,
} from '@credo-ts/cheqd'
import { AnonCredsModule } from '@credo-ts/anoncreds'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
const agent = new Agent({
config,
dependencies: agentDependencies,
modules: {
dids: new DidsModule({
registrars: [new CheqdDidRegistrar()],
resolvers: [new CheqdDidResolver()],
}),
// AnonCreds
anoncreds: new AnonCredsModule({
registries: [new CheqdAnonCredsRegistry()],
anoncreds,
}),
// Add cheqd module
cheqd: new CheqdModule(
new CheqdModuleConfig({
networks: [
{
network: '<mainnet or testnet>',
cosmosPayerSeed: '<cosmos payer seed or mnemonic>',
},
],
})
),
// Indy VDR can optionally be used with Askar as wallet and storage implementation
askar: new AskarModule({
askar,
}),
connections: new ConnectionsModule({
autoAcceptConnections: true,
}),
credentials: new CredentialsModule({
autoAcceptCredentials: AutoAcceptCredential.ContentApproved,
credentialProtocols: [
new V2CredentialProtocol({
credentialFormats: [new LegacyIndyCredentialFormatService(), new AnonCredsCredentialFormatService()],
}),
],
}),
},
})
The cosmosPayerSeed can be a 32-bit seed value or mnemonic. It can be managed using the Keplr wallet, which is available as a mobile app or browser extension for Chrome and Safari. Keplr enables users to create accounts, exchange tokens, etc. To setup Keplr wallet for cheqd follow this tutorial.
Next steps
Now that your Credo agent is successfully set up to work with cheqd, try following our tutorials for creating a new DID or issuing Verifiable Credentials.
Create a DID
Create an Issuer DID using the did:cheqd DID method.
Issue a Verifiable Credential
Issue a Verifiable Credential using Credo signed by a cheqd DID.