@docknetwork/cheqd-blockchain-modules

0.13.3 • Public • Published

Cheqd Blockchain Modules

Setup

Before using any module on the Cheqd blockchain, the initial setup is required to configure the necessary API connections and cryptographic elements. This setup is shared across all modules to ensure seamless interoperability and efficient management of Decentralized Identifiers (DIDs) and attestations.

Initialization

import { CheqdAPI } from '@docknetwork/cheqd-blockchain-api';
import { CheqdTestnetDid } from '@docknetwork/credential-sdk/types';
import { Ed25519Keypair, DidKeypair } from '@docknetwork/credential-sdk/keypairs';

// Initialize the Cheqd API connection
const cheqd = new CheqdAPI();
await cheqd.init(...);

// Create a random DID on the Cheqd Testnet
const did = CheqdTestnetDid.random();

// Generate a random Ed25519 keypair
const keyPair = Ed25519Keypair.random();

// Create a DidKeypair using the generated DID and keypair
const didKeypair = new DidKeypair([did, 1], keyPair);

DID

The CheqdDIDModule handles Decentralized Identifiers (DIDs) specifically on the Cheqd blockchain network. By extending from AbstractDIDModule, it utilizes Cheqd-specific functionalities to manage DID documents effectively.

Example

import { CheqdDIDModule } from "@docknetwork/cheqd-blockchain-modules";

// Initialize the DID module using the shared setup
const didModule = new CheqdDIDModule(cheqd);

// Create a DID document
const document = DIDDocument.create(did, [didKeypair.didKey()]);

// Create the DID document on the blockchain
await didModule.createDocument(document, didKeypair);

// Validate that the created document matches the expected JSON
expect((await didModule.getDocument(did)).toJSON()).toEqual(document.toJSON());

Attest

The CheqdAttestModule is a specialized extension of the AbstractAttestModule focused on managing attestations for Decentralized Identifiers (DIDs) on the Cheqd network.

Example

import { CheqdDIDModule } from "@docknetwork/cheqd-blockchain-modules";

// Initialize the Attest module using the shared setup
const attestModule = new CheqdAttestModule(cheqd);

// Define an Intersected Resource Identifier (IRI) for testing
const iri = "test";

// Set a claim for the given DID and DID keypair
await attestModule.setClaim(iri, did, didKeypair);

// Verify that the attestations on the document match the expected IRI
expect((await attestModule.getDocument(did)).attests.toJSON()).toEqual(iri);

TODO:

  • Accumulator
  • Anchor
  • Blob
  • OffchainSignatures params (BBS/BBSPlus/PS)
  • StatusListCredential
  • TrustRegistry

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.13.336latest

Version History

VersionDownloads (Last 7 Days)Published
0.13.336
0.13.111
0.13.07
0.12.03
0.11.226
0.11.13
0.11.03
0.10.11
0.10.01
0.8.02
0.7.12
0.7.02
0.5.31
0.5.21
0.5.12
0.5.02
0.4.03
0.3.02
0.1.02

Package Sidebar

Install

npm i @docknetwork/cheqd-blockchain-modules

Weekly Downloads

110

Version

0.13.3

License

MIT

Unpacked Size

323 kB

Total Files

108

Last publish

Collaborators

  • mayconmello
  • mikeatdock
  • samdock
  • lovesh_h