Back to Learn
getting started

Using the CLI

Learn how to set up and use the Stylus CLI to create, build, and deploy smart contracts.

Using the Stylus CLI

The Stylus CLI is your primary tool for developing smart contracts on Arbitrum Stylus. It handles project creation, compilation to WASM, and deployment.

Installation

First, ensure you have Rust installed, then install the Stylus CLI:

``bash

cargo install cargo-stylus

`

Creating a New Project

Create a new Stylus project with:

`bash

cargo stylus new my-project

cd my-project

`

This creates a new Rust project with the necessary Stylus dependencies and configuration.

Building Your Contract

Compile your contract to WASM:

`bash

cargo stylus check

cargo stylus build

`

The check command validates your contract without deploying, while build compiles it for deployment.

Deploying

Deploy to a Stylus-enabled chain:

`bash

cargo stylus deploy --private-key

``

You'll need an RPC endpoint and a funded wallet for deployment.

Code Example

# Install Stylus CLI
cargo install cargo-stylus

# Create new project
cargo stylus new my-first-contract
cd my-first-contract

# Check contract validity
cargo stylus check

# Build for deployment
cargo stylus build

# Deploy (requires private key and RPC)
cargo stylus deploy --private-key $PRIVATE_KEY

Key Points

  • Install with cargo install cargo-stylus
  • Create projects with cargo stylus new
  • Check contracts with cargo stylus check
  • Build with cargo stylus build
  • Deploy with cargo stylus deploy

Navigation