Skip to content

About

This repository is a monorepo which includes all the polygon related did modules and registries

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Polygon DID Modules

License Node.js TypeScript

A comprehensive suite of modules for implementing Polygon-based Decentralized Identifiers (DIDs) with W3C compliance, enabling secure identity management on the Polygon blockchain network.

Packages

This monorepo contains the following packages:

Package Description Version
credo-module Credo framework integration module npm
did-resolver Polygon DID resolver implementation npm
did-registrar DID registration and management npm
schema-manager W3C schema management utilities npm
did-registry-contract Smart contract for DID registry npm

Apps

App Description
demo-api Demo REST API (create/register/resolve/update DID) with Swagger UI and a browser playground, consuming the packages in this workspace via workspace:* - see apps/demo-api

Running the demo

The demo app serves three surfaces from one Express process on one port, so a single command is all you need:

pnpm install
pnpm build
pnpm --filter @ayanworks/polygon-did-demo-api dev

Then open:

Defaults to the Amoy testnet on port 8081; override with PORT, POLYGON_RPC_URL and POLYGON_CONTRACT_ADDRESS. See apps/demo-api/README.md for the endpoint reference and the local-signing walkthrough.

Browser and server usage

The packages work in both, which is worth knowing before you pick one:

Server (Node) Browser
Install npm install @ayanworks/polygon-did-registrar bundle with esbuild/Vite (platform: browser)
Node built-ins required none none - no polyfills, no Buffer shim
Key handling holds a key server-side, or relays a signed transaction key stays in the page; sign locally and broadcast the raw transaction
Reads RPC from the server RPC straight from the page, if the endpoint sends CORS headers

The libraries are pure TypeScript over ethers and touch no Node APIs, so the browser build is a plain bundle - roughly 900 KB raw, ~160 KB gzipped, essentially all ethers. See the did-registrar README for the exact command and a working example.

Both modes produce interchangeable documents. One caveat if you persist them: publicKeyBase58 changed in @ayanworks/polygon-did-registrar 3.0.0 to encode the 33 key bytes rather than the key's hex text. Values written by older versions are unusable and the document has to be re-published - see Repairing an affected DID.

Setup

# Clone the repository
git clone https://github.com/ayanworks/polygon-did-modules.git

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Type checking
pnpm types:check

# Code formatting
pnpm style:fix

About

This repository is a monorepo which includes all the polygon related did modules and registries

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages