This repository contains the Rust implementation of a CORD Network node based on the Substrate framework.
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:
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.
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.
Before you begin, ensure you have the necessary packages to locally run CORD.
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 :
Open a terminal shell on your computer.
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.
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
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
To get your local CORD node up and running, follow these steps:
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.
If you want to run the Braid runtime, use the following command:
bash
./target/release/cord --chain braid-dev --dev
To run the Loom runtime, use this command:
bash
./target/release/cord --chain loom-dev --dev
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.
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!
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.
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
Create a Docker volume:
sh
docker volume create cord
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
--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
CORD supports multiple runtimes, including Braid and Loom. To specify a runtime, you can add the runtime name before the --dev flag. For example:
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
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
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.
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.
There are 4 tests which run as part of PR validation.
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
Transform CORD codebase into executable binary.
bash
cargo build --release
Runs the linter to maintain clean and idiomatic code.
bash
cargo clippy --all --no-deps --all-targets --features=runtime-benchmarks -- -D warnings`
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.
The code in this repository is licensed under the terms of the GPL 3.0 licensed.