This guide provides detailed instructions for setting up a local development environment for Shardeum.
- Environment Setup
- Node.js and NVM
- Rust Toolchain
- Build Essentials
- Project Setup
- Network Configuration
- Running the Network
- Stopping and Cleaning Up
To run a Shardeum network for local development, you need to configure your machine to spin up local validator, archiver, and monitor servers.
Shardeum requires Node.js version 18.16.1 and npm version 9.5.1. We recommend using Node Version Manager (NVM) to manage multiple Node.js versions.
- Install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- Set NVM directory:
export NVM_DIR="$HOME/.nvm"
- Add the following to your
.bashrc
or.bash_profile
:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
- Install and use the correct Node.js version
nvm install 18.16.1
nvm use 18.16.1
- Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Import Rust environment variables:
source "$HOME/.cargo/env"
- Install and set the correct Rust version:
rustup install 1.74.1
rustup default 1.74.1
For Linux:
sudo apt-get install build-essential
For MacOS:
brew install gcc
Node-gyp
- Install node-gyp globally:
npm i -g node-gyp
- Configure Python version:
npm config set python `which python3`
- Verify the configuration:
npm config list
- Clone the repository:
git clone https://github.com/shardeum/shardeum.git
cd shardeum
- Install project dependencies:
npm ci
- Compile the project:
npm run prepare
- Install the Shardus CLI:
npm install -g shardus
npm update @shardus/archiver
You can configure the Shardeum network for local development using either the automatic or manual mode.
Apply a pre-configured patch:
git apply debug-10-nodes.patch
- Configure Debug Mode in
src/config/index.ts
forceBogonFilteringOn: false,
mode: 'debug'
- Modify flags in
src/shardeum/shardeumFlags.ts
:
txBalancePreCheck: false,
StakingEnabled: false
- Adjust settings for local testing:
// src/config/index.ts
cycleDuration: 30,
// src/shardeum/shardeumFlags.ts
blockProductionRate: 3,
- Recompile the project:
npm run prepare
Start a Shardeum network with 10 nodes:
shardus start 10
To stop the network and clean up resources:
shardus stop && shardus clean && rm -rf instances
This guide should help you set up and run a local Shardeum network for development purposes. If you encounter any issues, please refer to our community resources or open an issue on this repo.