Welcome to the StellarGive project! This comprehensive guide provides step-by-step instructions for getting your local development environment up and running on macOS, Linux, and Windows.
This guide will walk you through installing the necessary tools to contribute to StellarGive. You will set up:
- Rust and Cargo: For compiling Soroban smart contracts.
- Soroban CLI: For interacting with the Stellar network and deploying contracts.
- Node.js and npm: For running the Next.js frontend application.
- Git: For version control.
Estimated setup time: 15-30 minutes. Supported Operating Systems: macOS, Linux (Ubuntu/Debian), and Windows (via WSL2).
Before starting, ensure you have:
- An active Internet connection
- Terminal/Command Line access
- A GitHub account
- Basic familiarity with your operating system's terminal
- Recommended minimum hardware: 8GB RAM, 10GB free storage
On macOS, we recommend using Homebrew to manage packages.
- Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Install Git:
brew install git
- Install Rust:
brew install rust
- Install Soroban CLI:
(Note: The
brew install stellar-cli
stellar-clipackage provides thesorobancommands.) - Install Node.js:
brew install node
After installation, reload your shell to ensure your PATH is updated:
source ~/.zshrc(Or source ~/.bash_profile if you are using bash.)
These instructions are primarily for Ubuntu/Debian-based distributions. Other distributions can use their respective package managers (e.g., dnf, pacman).
- Install Prerequisites:
sudo apt update sudo apt install -y build-essential curl git
- Install Rust (via Rustup):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env"
- Install Soroban CLI:
cargo install --locked stellar-cli --features opt
- Install Node.js (via NodeSource for a recent version):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs
Verify your environment by running source ~/.bashrc (or your shell's config file) to reload the path.
IMPORTANT: We strongly recommend using WSL2 (Windows Subsystem for Linux) as your primary development environment.
Why WSL2? The Soroban toolchain and Rust ecosystem work significantly more reliably in Linux environments. Using WSL2 avoids complex PATH issues, compilation errors with node-gyp, and toolchain compatibility problems often encountered on native Windows.
- Install WSL2 and Ubuntu:
Open PowerShell as Administrator and run:
Restart your computer if prompted. This will install Ubuntu by default.
wsl --install - Open Windows Terminal (Highly Recommended, install from Microsoft Store).
- Open an Ubuntu tab in Windows Terminal.
- Follow the Linux Setup instructions above from inside your Ubuntu terminal.
If you must use native Windows, you can use Chocolatey:
choco install git
choco install rust
choco install nodejs
cargo install --locked stellar-cli --features optNote: You may need to install the Visual Studio C++ Build Tools for Rust compilation to work on native Windows.
Verify that all tools are successfully installed on your system by running the following commands:
rustc --version # Expected: Output showing the Rust compiler version
cargo --version # Expected: Output showing the Cargo package manager version
soroban --version # Expected: Output showing the Soroban CLI version
node --version # Expected: Output showing Node.js version (e.g., v20.x)
npm --version # Expected: Output showing npm version
git --version # Expected: Output showing Git versionIf any of these commands fail, revisit the installation steps for your platform.
- Fork the repository on GitHub by clicking the "Fork" button on the top right of the project page.
- Clone your fork:
git clone https://github.com/<your-username>/stellargive.git cd stellargive
- Set the upstream remote to sync with the original repository:
git remote add upstream https://github.com/Nursca/stellargive.git
The project uses npm for the frontend and cargo for the smart contracts.
- Frontend dependencies:
cd frontend npm ci cd ..
- Smart contract dependencies:
The Rust dependencies are automatically downloaded when you build or test the contract.
cd contracts/stellar-give cargo fetch cd ../..
The frontend relies on specific environment variables to connect to the contract and network.
- Create the base
.envfile:cp .env.example .env
- Create the frontend
.env.localfile:cp .env.example frontend/.env.local
- Append the testnet contract address to your local frontend config:
echo "NEXT_PUBLIC_CONTRACT_ADDRESS=CB6HVHRQYILGNKW7RBB66BC6TDBIEWADOA2YUUV4I22RXRLA6DY6OAKT" >> frontend/.env.local
Note: Never commit your actual .env files. The .env.example file contains safe, public placeholders or testnet values.
To deploy or interact with contracts on the testnet, you need an account and test network tokens.
- Generate a Soroban testnet key:
soroban keys generate --global test-key --network testnet
- Retrieve your public address:
Expected result: A Stellar public key starting with 'G' (e.g.,
soroban keys address test-key
GB...) - Fund your account using friendbot:
Replace
YOUR_PUBLIC_KEYwith the output from the previous step.Expected result: A JSON response indicating a successful transaction, meaning your account now has testnet XLM.curl -X POST "https://friendbot.stellar.org?addr=YOUR_PUBLIC_KEY"
Only use the commands currently supported by the repository.
Smart Contract Operations:
# Change to contract directory
cd contracts/stellar-give
# Format and lint
cargo fmt --check
cargo clippy -- -D warnings
# Run tests
cargo test
# Build WASM
cargo build --release --target wasm32-unknown-unknownFrontend Operations:
# Change to frontend directory
cd frontend
# Lint codebase
npm run lint
# Run development server
npm run dev
# Build for production
npm run build| Error | Cause | Solution |
|---|---|---|
soroban: command not found |
The CLI is not installed or not in PATH | Check installation. On Linux/Mac, ensure ~/.cargo/bin is in your PATH. On Mac, check if brew link stellar-cli is needed. |
cargo: command not found |
Rust is not installed or not in PATH | Install Rust via Rustup/Homebrew and restart your terminal. |
permission denied |
Missing execution rights on scripts/folders | Run chmod +x <filename> for scripts, or check directory ownership. |
| PATH issues | Shell doesn't know where tools are located | Add export PATH="$HOME/.cargo/bin:$PATH" to your ~/.bashrc or ~/.zshrc and reload. |
node-gyp issues |
Missing build tools for Node.js modules | On Linux, install build-essential. On Windows, stick to WSL2 or install Windows Build Tools. |
| WSL networking issues | Port forwarding failing between Windows and WSL | Run wsl --shutdown and restart your terminal. Ensure the dev server binds to 0.0.0.0 if necessary. |
npm install failures |
Incompatible Node.js version or network issue | Ensure you are on Node v20.x or higher. Clear cache with npm cache clean --force and retry. Use npm ci instead of npm install. |
| Rust target missing / wasm32 target issues | Missing WASM toolchain | Run rustup target add wasm32-unknown-unknown to install the target. |
When you're ready to make a contribution:
- Ensure your main branch is up to date:
git checkout main git pull upstream main
- Create a new branch for your feature or fix:
git checkout -b feat/my-feature # or git checkout -b fix/issue-description - Make your changes in your code editor.
- Run formatting, linting, and tests locally:
cd contracts/stellar-give && cargo test && cargo clippy cd ../../frontend && npm run lint
- Commit your changes with a clear message:
git commit -m "feat: implement new crowdfunding tier" - Push to your fork:
git push origin feat/my-feature
- Open a Pull Request against the main repository via the GitHub interface.
To ensure a smooth developer experience, we recommend using:
- Editor: VS Code
- Extensions:
rust-lang.rust-analyzer(Rust Analyzer for intelligent code completion)dbaeumer.vscode-eslint(ESLint for frontend linting)esbenp.prettier-vscode(Prettier for code formatting)vadimcn.vscode-lldb(CodeLLDB for Rust debugging)eamodio.gitlens(GitLens for in-editor git blame and history)