Before you start
Install Rust and build tools
Kaspad is written in Rust. rustup installs the compiler and cargo, its build tool.
Choose the default installation when asked:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThe build also needs a C compiler, clang and the protobuf compiler. The rusty-kaspa README keeps the current list for each system. On Debian or Ubuntu:
sudo apt install -y build-essential git pkg-config libssl-dev clang libclang-dev protobuf-compiler libprotobuf-devOn macOS:
xcode-select --install
brew install protobufClose and reopen the terminal, then check:
rustc --version
cargo --versionrustc --versionandcargo --versionprint versions- Neither says command not found
Get the code
Clone the official rusty-kaspa repository and switch to its stable branch, which the Kaspa developers recommend for running a node.
cd ~
git clone https://github.com/kaspanet/rusty-kaspa.git
cd rusty-kaspa
git checkout stable- kaspad/
- The node
- wallet/
- The command-line wallet
- rpc/
- The RPC server and client
- consensus/
- Consensus rules
Build kaspad
The first build is the slow one: cargo downloads and compiles every dependency. Later builds only recompile what changed.
cargo build --release --bin kaspad- --release
- Optimised: slower to build, faster to run
- --bin kaspad
- Builds only the node, not every program in the workspace
When it finishes, the program is here. Check it runs:
./target/release/kaspad --version- cargo finishes without errors
target/release/kaspadexistskaspad --versionprints a version
Run your build
Run it from where it was built to try it, or copy it somewhere on your PATH.
From the build folder (Ctrl+C stops it):
cd ~/rusty-kaspa
./target/release/kaspad --utxoindex --appdir=~/.kaspadTo run it from anywhere:
sudo cp target/release/kaspad /usr/local/bin/
kaspad --version- --utxoindex
- Keeps an index for balance lookups (recommended)
- --rpclisten=127.0.0.1:16110
- Turns on RPC for this machine only
- --appdir=~/.kaspad
- Keeps the chain where the kaspad guides do
- --loglevel=debug
- More detail in the log
Keep it running
Optional: run it as a service so it starts with the machine and restarts if it stops.
Service setup is the same as for a downloaded kaspad; use your own build's path. See the macOS (launchd) or Linux (systemd) guides. The shortest version, for Linux:
[Unit]
Description=Kaspa node (kaspad, own build)
After=network.target
[Service]
Type=simple
User=YOUR_USERNAME
ExecStart=/usr/local/bin/kaspad --utxoindex --appdir=/home/YOUR_USERNAME/.kaspad
Restart=on-failure
RestartSec=10
LimitNOFILE=65536
[Install]
WantedBy=multi-user.targetReplace YOUR_USERNAME, then:
sudo systemctl enable --now kaspadUpdate your build
Pull the newest code and rebuild. With dependencies already compiled this usually takes 2 to 5 minutes.
# Stop the node first (Ctrl+C, or: sudo systemctl stop kaspad)
cd ~/rusty-kaspa
git pull origin stable
cargo build --release --bin kaspad
# If you copied it to /usr/local/bin, copy it again:
sudo cp target/release/kaspad /usr/local/bin/
# Start it again (./target/release/kaspad, or: sudo systemctl start kaspad)To see what is new before pulling:
cd ~/rusty-kaspa
git fetch origin
git log HEAD..origin/stable --onelineTo build a particular release instead, check out its tag from the releases page, and git checkout stable to come back:
git checkout v<version>
cargo build --release --bin kaspadTroubleshooting
The usual problems and what fixes them.
rustc or cargo not found after installing
Close and reopen the terminal. If that doesn't help, run source $HOME/.cargo/env, and check ~/.cargo/bin is on your PATH.
The build fails with out of memory, or Killed
Build with fewer jobs at once: cargo build --release --bin kaspad -j 2, and close other programs. With less than 16 GB, the machine is too small to run a node anyway.
The build fails with linker or protoc errors
A compiler, clang or the protobuf compiler is missing. macOS: xcode-select --install and brew install protobuf. Debian or Ubuntu: sudo apt install build-essential clang libclang-dev protobuf-compiler. Fedora: sudo dnf groupinstall 'Development Tools', then clang-devel and protobuf-compiler.
git pull reports conflicts
If you haven't changed anything, git reset --hard origin/stable matches the remote exactly. If you have your own changes, git stash, git pull, then git stash pop.
kaspad --version still shows the old version
You may be running an old copy. Copy the new build to /usr/local/bin again, and check which one runs with which kaspad.
The systemd service won't start after an update
Read sudo journalctl -u kaspad.service -n 50. Usually the path in ExecStart is wrong, the program isn't executable (chmod +x /usr/local/bin/kaspad), or an old kaspad is still running (ps aux | grep kaspad).
Builds are very slow
The first build always is. A build without --release compiles faster but runs slower; -j 2 helps when memory is short; and sccache caches compiled code between builds.
Running? Put your name on it.
Once the node shows up in a crawl you can claim it, pick a public name and follow its rank.