MCPcopy Index your code
hub / github.com/dhiway/cord

github.com/dhiway/cord @v0.9.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.9.8 ↗ · + Follow
5,002 symbols 10,396 edges 524 files 2,504 documented · 50%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

This repository contains the Rust implementation of a CORD Network node based on the Substrate framework.

CORD

CORD is a global public utility and trust framework designed to address trust gaps, manage transactions, and facilitate the exchange of value at scale.

It simplifies the management of information, making it easier for owners to control their data. Agencies and businesses can discover, access, and use this data to deliver networked public services. CORD provides a transparent history of information, protecting it from unauthorized tampering both inside and outside the system.

Building on the modular approach of the Substrate framework, CORD defines a rich set of primitives to foster exceptional innovation across various industries. These innovations support transactions and record maintenance in sectors such as finance, trade, health, energy, water resources, agriculture, and many more.

CORD now supports multiple runtimes, each tailored to different types of networks:

  • Braid: Optimized for enterprise networks, Braid functions without on-chain governance. It’s ideal for private, high-performance environments where speed and efficiency are crucial.
  • Loom: Designed for ecosystem-level networks, Loom incorporates on-chain governance. It excels at managing and coordinating multi-party networks, making it suitable for sectors that require robust governance and regulatory compliance.
  • Weave: Targeted at permissionless networks, Weave is intended for open and decentralized environments where anyone can participate without prior authorization. Please note that Weave is currently a work in progress, with ongoing development to enhance its capabilities.

By offering these distinct runtimes, CORD provides a versatile foundation tailored to meet the specific needs of various industries and applications, enhancing its ability to deliver effective networked public services.

Get Started

The first step in becoming a blockchain developer with CORD is to learn how to compile and launch a single local blockchain node. In this tutorial, you'll build and start a single node blockchain using the CORD framework.

The CORD repository provides everything you need to set up a fully functional single-node blockchain that you can run locally in your development environment. This setup includes several predefined components—such as user accounts, assets, smart-contracts, governance, identifiers, statements, chain-space—allowing you to experiment with common tasks right away. You can build and run the node as-is to produce blocks and facilitate transactions immediately.

Prerequisites

Before you begin, ensure you have the necessary packages to locally run CORD.

Compile a CORD node

If you have already compiled the node on the local computer, you can skip this section and continue to Start the local node.

To compile the node :

  1. Open a terminal shell on your computer.

  2. Clone the cord node repository by running the following command:

bash git clone https://github.com/dhiway/cord.git

This command clones the develop branch.

  1. Change to the root of the CORD node directory by running the following command:

bash cd cord

Create a new branch to contain your work:

bash git switch -c my-branch-yyyy-mm-dd

Replace yyyy-mm-dd with any identifying information that you desire, but we recommend a numerical year-month-day format. For example:

bash git switch -c my-branch-2024-06-01

  1. Compile the node by running the following command:

bash cargo build --release

You should always use the --release flag to build optimized artifacts. The first time you compile this, it takes some time to complete.

It should complete with a line something like this:

bash Finished release [optimized] target(s) in 5m 23s

Start the local node

To get your local CORD node up and running, follow these steps:

  1. Start the node in development mode:

In the terminal where you compiled your node, run the following command:

bash ./target/release/cord --dev

This command starts the node in development mode using the predefined loom development chain specification. The --dev option ensures the node runs in a clean working state each time you restart it, deleting all active data such as keys, the blockchain database, and networking information. If you don't specify a runtime, the loom runtime is used by default.

  1. Start the Braid node in development mode:

If you want to run the Braid runtime, use the following command:

bash ./target/release/cord --chain braid-dev --dev

  1. Start the Loom node in development mode:

To run the Loom runtime, use this command:

bash ./target/release/cord --chain loom-dev --dev

  1. Verify your node is up and running successfully by reviewing the output displayed in the terminal.

The terminal should display output similar to this:

text 2024-06-11 16:22:52 Dhiway CORD 2024-06-11 16:22:52 ✌️ version 0.9.3-5cd85df03fb 2024-06-11 16:22:52 ❤️ by Dhiway Networks <info@dhiway.com>, 2019-2024 2024-06-11 16:22:52 📋 Chain specification: Loom Development 2024-06-11 16:22:52 🏷 Node name: low-pull-3415 2024-06-11 16:22:52 👤 Role: AUTHORITY 2024-06-11 16:22:52 💾 Database: ParityDb at /var/folders/ww/gtrj_81s6hj7p_6bd0b3qgb00000gn/T/substrateyVRCDn/chains/loom-dev/paritydb/full 2024-06-11 16:22:55 🔨 Initializing Genesis block/state (state: 0x717a…e54e, header-hash: 0x1ae3…3314) 2024-06-11 16:22:55 👴 Loading GRANDPA authority set from genesis on what appears to be first startup. 2024-06-11 16:22:55 👶 Creating empty BABE epoch changes on what appears to be first startup. 2024-06-11 16:22:55 🏷 Local node identity is: 12D3KooWButjQ1xjMkDM8BDLrJipvqBNcGhLnRWJTR5MbU1YaMUN ... ... ... ... 2024-06-11 16:23:05 💤 Idle (0 peers), best: #3 (0x3a75…1901), finalized #1 (0x1ab2…ff17), ⬇ 0 ⬆ 0

If the number after finalized is increasing, your blockchain is producing new blocks and reaching consensus about the state they describe.

  1. Keep the terminal that displays the node output open to continue.

These steps will help you set up and experiment with different runtimes supported by CORD, each tailored to specific network requirements. Enjoy exploring the versatile capabilities of the CORD framework!

Using Docker

Install Docker

If Docker is not installed on your system, you can check by running: which docker. To install Docker, follow the official installation documentation.

  1. First, let's check the version of CORD. The first time you run this command, the CORD Docker image will be downloaded. This may take some time and bandwidth, so please be patient:

bash docker run --rm dhiway/cord --version

You can also pass any argument or flag that CORD supports:

bash docker run --name "CordDocker" --rm dhiway/cord --dev

  1. Once you are done experimenting and picking the best node name, you can start CORD as a daemon, exposing the necessary ports and mounting a volume to store your blockchain data locally. Make sure to create a Docker volume for mounting or pass a separate mount (disk) for the process.

Create a Docker volume:

sh docker volume create cord

  1. To start a CORD node with the default RPC port 9933, default P2P port 30333, and default Prometheus port 9615, use the following command:

bash docker run -d -p 9944:9944 -p 30333:30333 -p 9933:9933 -p 9615:9615 -v cord:/data dhiway/cord:develop --dev --rpc-external --rpc-cors all

  1. If you want to specify a custom node name, add the arg --name "YourName" to the command:

bash docker run --name "CordDocker" -d -p 9944:9944 -p 30333:30333 -p 9933:9933 -p 9615:9615 -v cord:/data dhiway/cord --dev --rpc-external --rpc-cors all

Note on Using Braid and Loom Runtimes

CORD supports multiple runtimes, including Braid and Loom. To specify a runtime, you can add the runtime name before the --dev flag. For example:

  • To start a Braid runtime node:

bash docker run --name "CordDocker" -d -p 9944:9944 -p 30333:30333 -p 9933:9933 -p 9615:9615 -v cord:/data dhiway/cord:develop braid --dev --rpc-external --rpc-cors all

  • To start a Loom runtime node:

bash docker run --name "CordDocker" -d -p 9944:9944 -p 30333:30333 -p 9933:9933 -p 9615:9615 -v cord:/data dhiway/cord:develop loom --dev --rpc-external --rpc-cors all

Other projects of interest

This repository contains the complete code for the CORD blockchain framework. To effectively interact with the chain, you may need several additional components:

  • CORD.js: This SDK is essential for building applications that use CORD. It provides methods to interact with the CORD node, enabling seamless integration and interaction with the network.

  • Apps UI: This user interface project is managed through the apps repository, providing an intuitive way to interact with the network.

  • Telemetry: Monitor the network through this telemetry interface.

  • GraphQL Interface: Currently in beta, this interface facilitates advanced data queries and is under development in the cord-subql repository.

  • Demo Scripts: Explore these demo scripts to connect and interact with the CORD Chain pallets/modules. They utilize the cord.js SDK to facilitate chain interactions.

Contributing

If you would like to contribute, please fork the repository, follow the contributions guidelines, introduce your changes and submit a pull request. All pull requests are warmly welcome.

Before submitting the PR

There are 4 tests which run as part of PR validation.

  • Cargo Format

Ensures the code format is in accordance with official Rust guidelines. Add the formatted files as part of the commit.

bash cargo +nightly fmt --all

  • Build

Transform CORD codebase into executable binary.

bash cargo build --release

  • Clippy

Runs the linter to maintain clean and idiomatic code.

bash cargo clippy --all --no-deps --all-targets --features=runtime-benchmarks -- -D warnings`

  • Test

Runs CORD Network unit tests, integration tests and benchmarks defined for all modules.

bash cargo test --release --locked --features=runtime-benchmarks --no-fail-fast --verbose --color always --all --all-targets

Note that each of these would take significant time to run, and hence, if you are working on a specific pallet, you can use -p <pallet-name> --lib instead of --all. That should be faster than normal full test locally.

License

The code in this repository is licensed under the terms of the GPL 3.0 licensed.

Extension points exported contracts — how you extend this code

IsPermissioned (Interface)
Trait definition for network type [10 implementers]
primitives/cord/src/lib.rs
IsMember (Interface)
Determine if a `MemberId` is a valid member. [5 implementers]
primitives/network-membership/src/lib.rs
Config (Interface)
(no doc) [58 implementers]
runtimes/weave/src/networks_registrar/mod.rs
Config (Interface)
(no doc) [90 implementers]
runtimes/common/authorities/src/lib.rs
CallSources (Interface)
The sources of a call struct. This trait allows to differentiate between the sender of a call and the subject of the ca [4 …
utilities/src/traits.rs
Config (Interface)
(no doc) [128 implementers]
origin/relay/runtime/src/governance/origins.rs
Config (Interface)
(no doc) [6 implementers]
pallets/network-score/src/lib.rs
Config (Interface)
(no doc) [6 implementers]
pallets/registries/src/lib.rs

Core symbols most depended-on inside this repo

encode
called by 2070
pallets/identity/src/types.rs
clone
called by 946
pallets/did-name/src/did_name.rs
new
called by 709
test-utils/runtime/client/src/lib.rs
build
called by 210
test-utils/runtime/src/extrinsic.rs
clone
called by 202
node/testing/src/bench.rs
clone
called by 165
test-utils/service/src/lib.rs
import
called by 97
test-utils/client/src/client_ext.rs
new_test_ext
called by 92
pallets/did/src/mock.rs

Shape

Method 3,199
Function 1,100
Class 483
Enum 125
Interface 95

Languages

Rust100%

Modules by API surface

pallets/did/src/tests.rs92 symbols
runtimes/weave/src/weights/pallet_contracts.rs82 symbols
runtimes/loom/src/weights/pallet_contracts.rs82 symbols
origin/relay/runtime/src/lib.rs68 symbols
origin/relay/runtime/src/weights/xcm/mod.rs58 symbols
origin/container/entity/src/weights/xcm/mod.rs55 symbols
origin/container/coretime/src/weights/xcm/mod.rs55 symbols
pallets/registries/src/tests.rs46 symbols
test-utils/runtime/src/lib.rs44 symbols
test-utils/runtime/transaction-pool/src/lib.rs40 symbols
runtimes/weave/src/weights/pallet_nfts.rs40 symbols
pallets/identity/src/tests.rs39 symbols

For agents

$ claude mcp add cord \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page