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:
git clone https://github.com/dhiway/cord.git
This command clones the develop
branch.
Change to the root of the CORD node directory by running the following command:
cd cord
Create a new branch to contain your work:
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:
git switch -c my-branch-2024-06-01
Compile the node by running the following command:
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:
Finished release [optimized] target(s) in 5m 23s
To get your local CORD node up and running, follow these steps:
Start the node in development mode:
In the terminal where you compiled your node, run the following command:
./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.
Start the Braid node in development mode:
If you want to run the Braid runtime, use the following command:
./target/release/cord braid --dev
Start the Loom node in development mode:
To run the Loom runtime, use this command:
./target/release/cord loom --dev
Verify your node is up and running successfully by reviewing the output displayed in the terminal.
The terminal should display output similar to this:
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.
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!
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.
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:
docker run --rm dhiway/cord --version
You can also pass any argument or flag that CORD supports:
docker run --name "CordDocker" --rm dhiway/cord --dev
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:
docker volume create cord
To start a CORD node with the default RPC port 9933, default P2P port 30333, and default Prometheus port 9615, use the following command:
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
If you want to specify a custom node name, add the arg --name "YourName"
to the command:
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:
To start a Braid runtime node:
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:
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 3 tests which run as part of PR validation.
Build - cargo build --release
Clippy - cargo clippy --all --no-deps --all-targets --features=runtime-benchmarks -- -D warnings
Test - 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.