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 that is designed to address trust gaps, manage transactions and exchange value at scale.
It is designed to simplify the management of information, making it easier for owners to control; agencies and businesses to discover, access and use data to deliver networked public services. It provides a transparent history of information and protects it from unauthorized tampering from within or without the system.
CORD builds on the modular approach of the Substrate framework. It defines a rich set of primitives to help design exceptional levels of innovations for existing and emerging industries. Such innovative approaches cover conducting transactions and maintaining records across several sectors such as finance, trade, health, energy, water resources, agriculture and many more.
This section will guide you through the following steps needed to prepare a computer for CORD development. Since CORD is built with the Rust programming language, the first thing you will need to do is prepare the computer for Rust development - these steps will vary based on the computer's operating system.
Once Rust is configured, you will use its toolchains to interact with Rust projects; the commands for Rust's toolchains will be the same for all supported, Unix-based operating systems.
Also, join and discover the various discord channels where you can engage, participate and keep up with the latest developments.
Use a terminal shell to execute the following commands:
sudo apt update
# May prompt for location information
sudo apt install -y git clang curl libssl-dev llvm libudev-dev pkg-config
Run these commands from a terminal:
pacman -Syu --needed --noconfirm curl git clang
Run these commands from a terminal:
sudo dnf update
sudo dnf install clang curl git openssl-devel
Run these commands from a terminal:
sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel
Open the Terminal application and execute the following commands:
# Install Homebrew if necessary https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Make sure Homebrew is up-to-date, install openssl
brew update
brew install openssl
This guide uses https://rustup.rs installer and the rustup
tool to manage the Rust toolchain.
First, install and configure rustup
:
# Install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Configure
source ~/.cargo/env
Configure the Rust toolchain to default to the latest stable version, add nightly and the nightly wasm target:
rustup default stable
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
You can use rustup to install a specific version of rust, including its custom compilation targets. Using rustup, it should set a proper toolchain automatically while you call rustup show within project's root directory. Naturally, we can try to use different versions of these dependencies, i.e. delivered by system's default package manager. To compile the CORD node:
-
Clone this repository by running the following command:
git clone https://github.com/dhiway/cord
-
Change to the root of the node template directory by running the following command:
cd cord git checkout develop
-
Compile by running the following command:
cargo build --release
You should always use the
--release
flag to build optimized artifacts.
-
Start the single-node development chain, by running:
./target/release/cord --dev
-
Detailed logs may be shown by running the chain with the following environment variables set:
RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/cord --dev
-
Additional CLI usage options
./target/release/cord --help
The easiest/faster option to run CORD in Docker is to use the latest release images. These are small images that use the latest official release of the CORD binary, pulled from our package repository.
-
Let's first check the version we have. The first time you run this command, the CORD docker image will be downloaded. This takes a bit of time and bandwidth, be patient:
docker run --rm -it dhiway/cord:develop --version
You can also pass any argument/flag that CORD supports:
docker run --rm -it dhiway/cord:develop --dev --name "CordDocker"
Once you are done experimenting and picking the best node name :) you can start CORD as daemon, exposes the CORD ports and mount a volume that will keep your blockchain data locally. Make sure that you set the ownership of your local directory to the CORD user that is used by the container. Set user id 1000 and group id 1000, by running
chown 1000.1000 /my/local/folder -R
if you use a bind mount. -
To start a CORD node on default rpc port 9933 and default p2p port 30333 use the following command. If you want to connect to rpc port 9933, then must add CORD startup parameter:
--rpc-external
.docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/cord dhiway/cord:develop --dev --rpc-external --rpc-cors all
-
Additionally if you want to have custom node name you can add the
--name "YourName"
at the enddocker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/cord dhiway/cord:develop --dev --rpc-external --rpc-cors all --name "CordDocker"
-
If you also want to expose the webservice port 9944 use the following command:
docker run -d -p 30333:30333 -p 9933:9933 -p 9944:9944 -v /my/local/folder:/cord dhiway/cord:develop --dev --ws-external --rpc-external --rpc-cors all --name "CordDocker"
-
To get up and running with the smallest footprint on your system, you may use the CORD Docker image. You can build it yourself (it takes a while...).
docker build -t local/cord:develop .
This repository contains the complete code of the CORD Network Blockchain. To interact with the chain, one needs multiple things.
- SDK to connect and build on top.
- Check CORD.js repository for SDK development. You can interact with the pallets implemented here through the corresponding modules in the
cord.js
project.
- A UI to explore the chain.
-
There are multiple projects which are required when we need to monitor the chain, and make use of the transactions.
-
Telemetry - This is hosted through 'substrate-telemetry' project.
-
GraphQL Interface - This project is still in beta. Development work is happening at cord-subql repository.
- Demostratable scripts and services, so one can take and build upon
-
Demo Scripts - Demo scripts are provided to connect and interact with the CORD Chain pallets/modules. This uses CORD.js SDK to interact with chain.
-
Demo API Service - Demo API Server using nodejs/express.js combination, which uses SDK to in backend and provides basic APIs and also provides a mechanism to store application data in DB, so data along with chain interactions can be managed.
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.
The code in this repository is licensed under the terms of the GPL 3.0 licensed.