{"id":45572525,"url":"https://github.com/paritytech/contract-dependency-manager","last_synced_at":"2026-05-12T05:01:55.904Z","repository":{"id":340069198,"uuid":"1155610388","full_name":"paritytech/contract-dependency-manager","owner":"paritytech","description":"Coordinates dependencies between on-chain contracts","archived":false,"fork":false,"pushed_at":"2026-04-02T19:11:49.000Z","size":3456,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T01:44:36.280Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://contracts.dot.li","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paritytech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-11T17:48:23.000Z","updated_at":"2026-04-02T19:11:53.000Z","dependencies_parsed_at":"2026-03-06T18:07:41.291Z","dependency_job_id":null,"html_url":"https://github.com/paritytech/contract-dependency-manager","commit_stats":null,"previous_names":["paritytech/contract-dependency-manager"],"tags_count":142,"template":false,"template_full_name":null,"purl":"pkg:github/paritytech/contract-dependency-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fcontract-dependency-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fcontract-dependency-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fcontract-dependency-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fcontract-dependency-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paritytech","download_url":"https://codeload.github.com/paritytech/contract-dependency-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fcontract-dependency-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31520577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-23T08:24:39.545Z","updated_at":"2026-05-12T05:01:55.886Z","avatar_url":"https://github.com/paritytech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contract Dependency Manager (CDM)\n\nA CLI tool for managing PVM smart contract dependencies on Polkadot. CDM automates contract deployment ordering, cross-contract address resolution, and TypeScript type generation.\n\nBrowse published contracts at [contracts.dot.li](https://contracts.dot.li/#/).\n\n## Table of Contents\n\n- [Install CLI](#install)\n- [Quick Start](#quick-start)\n- [Writing CDM Contracts](#writing-cdm-contracts)\n- [Using CDM Contracts from TypeScript](#using-contracts-from-typescript)\n- [Example: Shared Counter](#example-shared-counter)\n- [Commands](#commands)\n\n## Install\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/paritytech/contract-dependency-manager/main/install.sh | bash\n```\n\nThis installs the `cdm` binary, the Rust nightly toolchain with `rust-src`, and `cargo-pvm-contract`.\n\n## Quick Start\n\n```bash\n# Scaffold a new project (current workspace directory)\ncdm template shared-counter\n\n# Initialize, fund \u0026 map dev account for deploying to paseo\ncdm init\ncdm account map -n paseo\n\n# Deploy all workspace contracts\ncdm deploy -n paseo\n```\n\n\u003e **Important:** Before deploying, open each contract's `lib.rs` and change the org name from `\"example\"` to your own unique org name (e.g. `\"myteam\"`). Contract names are scoped by org, so deploying with `\"example\"` will conflict with other users.\n\n## Writing CDM Contracts\n\nAnnotate your contract with a CDM package name:\n\n```rust\n#[pvm::contract(cdm = \"@yourorg/mycontract\")]\nmod mycontract {\n    #[pvm::constructor]\n    pub fn new() -\u003e Result\u003c(), Error\u003e { Ok(()) }\n\n    #[pvm::method]\n    pub fn do_something() -\u003e u32 { 42 }\n}\n```\n\nTo call another CDM contract:\n\n```rust\ncdm::import!(\"@someorg/other_contract\")\n\n// Add the contract as a cdm dependency using `cdm install`\n// Then use cdm_reference() for runtime address lookup\nlet other = other_contract::cdm_reference();\nother.do_something().expect(\"call failed\");\n```\n\n## Using Contracts from TypeScript\n\nAfter deploying contracts, you can interact with them from TypeScript using `@dotdm/cdm`.\n\n### 1. Install contract ABIs\n\n```bash\ncdm install -n paseo @yourorg/counter @yourorg/counter-writer @yourorg/counter-reader\n```\n\nThis fetches contract ABIs from the on-chain registry, saves them to `cdm.json`, and generates TypeScript types in `.cdm/cdm.d.ts`. You get full autocomplete and type safety for every contract method.\n\n### 2. Create a CDM instance and call contracts\n\n```typescript\nimport { createCdm } from \"@dotdm/cdm\";\n\n// Reads cdm.json from cwd, connects to the chain automatically\nconst cdm = createCdm({ defaultSigner: signer });\n\n// Get typed contract handles\nconst counter = cdm.getContract(\"@yourorg/counter\");\nconst counterWriter = cdm.getContract(\"@yourorg/counter-writer\");\n\n// Query (read-only, no transaction)\nconst count = await counter.getCount.query();\nconsole.log(count); // { success: true, value: 0 }\n\n// Send a transaction (state-changing)\nawait counterWriter.writeIncrement.tx();\n\n// Clean up WebSocket connection\ncdm.destroy();\n```\n\nEvery contract method exposes `.query()` for dry-run reads and `.tx()` for signed transactions. Arguments are positional:\n\n```typescript\nawait counterWriter.writeIncrementN.tx(5);\n```\n\n### 3. Custom signer\n\nBy default `createCdm()` uses the Alice dev account. To use a custom signer, pass it to `.tx()`:\n\n```typescript\nawait counter.increment.tx({ signer: myPolkadotSigner });\n```\n\n## Example: Shared Counter\n\nThe included shared-counter template demonstrates a 3-contract system:\n\n- **counter** - Stores a shared count value\n- **counter-writer** - Calls counter to increment (depends on counter via CDM)\n- **counter-reader** - Queries counter for the current value (depends on counter via CDM)\n\n```\ncdm template shared-counter\ncdm deploy deploy -n paseo\ncdm install @\u003cyourorg\u003e/counter @\u003cyourorg\u003e/counter-writer @\u003cyourorg\u003e/counter-reader\n\nbun run src/index.ts\n```\n\n## Commands\n\n### `cdm build`\n\nBuild all contracts with the ContractRegistry address baked in.\n\n```bash\ncdm build --contracts counter counter_writer    # Build specific contracts\ncdm build -n preview-net                        # Embed that network's registry\ncdm build --root /path/to/workspace             # Custom workspace root\n```\n\n### `cdm deploy -n \u003cchain\u003e`\n\nBuild \u0026 deploy/register all contracts\n\n```bash\ncdm deploy -n paseo\n\n# Options\ncdm deploy -n paseo --suri //Bob  # Use different signer\ncdm deploy --registry-address 0x... --assethub-url wss://... --bulletin-url wss://...\n```\n\n### `cdm install -n \u003cchain\u003e \u003clibrary\u003e`\n\nAdd a CDM contract library for use with `@dotdm/cdm` or  the polkadot-api. Queries the on-chain registry for the contract's ABI metadata and installs it locally.\n\n```bash\ncdm i -n paseo @polkadot/reputation @polkadot/disputes\ncdm i -n preview-net @polkadot/reputation\n```\n\n### `cdm template [name]`\n\nScaffold a complete example project with 3 contracts demonstrating cross-contract CDM dependencies.\n\n```bash\ncdm template shared-counter\n```\n\n## Development\n\n```bash\ngit clone https://github.com/paritytech/contract-dependency-manager.git\ncd contract-dependency-manager\nmake setup\n\n# Run in dev mode\nbun run src/apps/cli/src/cli.ts --help\n\n# Run tests\nmake test\n\n# Build native binary\nmake compile\n\n# Cross-compile for all platforms\nmake compile-all\n```\n\n## Architecture\n\n```\nsrc/\n  apps/\n    cli/                  CLI tool (Commander.js, Bun runtime)\n      src/\n        cli.ts            Entry point\n        commands/          build, deploy, install, template\n        lib/              Pipeline orchestration, Ink UI\n    frontend/             Web dashboard (React 19, Vite)\n  lib/\n    contracts/            @dotdm/contracts — Detection, deployer, publisher, registry, builder\n    env/                  @dotdm/env — Chain connections, signer, chain presets\n    utils/                @dotdm/utils — Shared constants, utilities\n    scripts/              @dotdm/scripts — embed-templates, deploy-registry\n    cdm/                  Stub packages (Rust + TypeScript)\n  contract/               ContractRegistry (Rust/PolkaVM)\n  templates/              Project scaffolding templates\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fcontract-dependency-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparitytech%2Fcontract-dependency-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fcontract-dependency-manager/lists"}