This guide walks you through setting up a local development environment for PropChain Smart Contracts.
| Tool | Minimum Version | Notes |
|---|---|---|
| Rust | 1.70 (stable) | Install via rustup |
| cargo-contract | 4.x | cargo install cargo-contract |
| Docker | 24.x | Required for local Substrate node |
| Git | 2.x | Version control |
# Install stable toolchain with required components
rustup toolchain install stable
rustup component add rustfmt clippy
# Install nightly toolchain for macro formatting
rustup toolchain install nightly
rustup component add --toolchain nightly rustfmt
# Add the WASM compilation target
rustup target add wasm32-unknown-unknowngit clone https://github.com/MettaChain/PropChain-contract.git
cd PropChain-contract
# Install Rust toolchain and project deps
./scripts/setup.sh
# Build all contracts (debug mode)
./scripts/build.sh
# Build optimised WASM bundles
./scripts/build.sh --release# Run the full workspace test suite
cargo test --all-features --workspace
# Run a single contract's tests
cargo test -p propchain-lending
# Run with coverage (requires cargo-llvm-cov)
./scripts/run_tests_with_coverage.sh# Check formatting (stable)
cargo fmt --check
# Check formatting including ink! macro matchers (nightly)
cargo +nightly fmt --check
# Run Clippy lints
cargo clippy --all-targets --all-features -- -D warningsThe project ships a rustfmt.toml in the repo root that enables
format_macro_matchers = true so that #[ink::contract], #[ink::test],
and propchain_traits::non_reentrant! macro bodies are formatted
consistently.
Apply nightly formatting with:
cargo +nightly fmt# Start a local Substrate node via Docker
docker-compose up -d
# Or use the helper script
./scripts/local-node.sh# Install the pre-commit hook set
./scripts/setup-pre-commit.shThe hooks run cargo fmt --check and cargo clippy before every commit.
Install the rust-analyzer extension. A recommended .vscode/settings.json:
{
"rust-analyzer.checkOnSave.command": "clippy",
"rust-analyzer.cargo.features": "all"
}Use the official Rust plugin. Enable "Run clippy instead of check" in the Rust plugin settings.
| Symptom | Fix |
|---|---|
error: linker 'cc' not found |
apt-get install build-essential |
| WASM target missing | rustup target add wasm32-unknown-unknown |
| cargo-contract not found | cargo install cargo-contract --force |
| Docker node won't start | Check docker-compose logs substrate-node |