Skip to main content

Prerequisites and setup

This guide will help you set up everything you need to develop Stylus contracts.

System requirements

  • Operating System: macOS, Linux, or Windows (WSL2)
  • RAM: Minimum 8GB, 16GB recommended
  • Disk Space: At least 20GB free

Install Rust

Installing Rust

The Rust toolchain includes rustc (compiler), cargo (package manager), and rustup (version manager).

macOS/Linux:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Windows:

Download and run rustup-init.exe.

Configure for WASM:

rustup target add wasm32-unknown-unknown

Verify:

rustc --version
cargo --version

Install cargo-stylus CLI

Installing cargo-stylus

The cargo-stylus CLI tool helps you create, build, and deploy Stylus contracts.

Install:

cargo install cargo-stylus

Verify:

cargo stylus --version

Update:

cargo install cargo-stylus --force

Install Docker (for local testnet)

Installing Docker for local testing

A local Arbitrum Nitro devnode allows you to test contracts before deploying to testnet.

macOS:

Download Docker Desktop for Mac.

Linux:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Windows:

Download Docker Desktop for Windows (requires WSL2).

Start Nitro devnode:

git clone https://github.com/OffchainLabs/nitro-devnode.git
cd nitro-devnode
./run-dev-node.sh

Verify:

curl -X POST http://localhost:8547 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Verify installation

# Check Rust version
rustc --version

# Check cargo-stylus
cargo stylus --version

# Check Docker
docker --version

Expected output:

rustc 1.75.0 (or higher)
cargo-stylus 0.x.x
Docker version 24.0.0 (or higher)

Next steps