DOCUMENTATION

Build with Stylus

Everything you need to start experimenting with Rust-powered smart contracts on Arbitrum.

Getting Started

Arbitrum Stylus allows you to write smart contracts in Rust, compiled to WebAssembly for efficient onchain execution.

Prerequisites

  • Rust toolchain installed (rustc, cargo)
  • Basic understanding of smart contracts
  • Familiarity with Rust programming

Install Rust

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

Clone the Repository

git clone https://github.com/signorecello/fun-with-stylus.git
cd fun-with-stylus

Install Stylus CLI

cargo install --force cargo-stylus

Example Contracts

Explore minimal, production-ready contract examples that demonstrate core Stylus patterns.

CONTRACT

Escrow

View Source

A trustless escrow system that holds funds until conditions are met. Features arbiter-controlled release and dispute resolution.

Key Features:

  • Three-party system: buyer, seller, arbiter
  • Funds locked until arbiter approves release
  • Built-in dispute resolution mechanism
Usage Example:
// Initialize escrow
let escrow = Escrow::new(buyer, seller, arbiter, amount);

// Buyer deposits funds
escrow.deposit(amount);

// Arbiter releases to seller after verification
escrow.release();
CONTRACT

Ballot

View Source

Commit-reveal voting pattern that ensures privacy and prevents vote manipulation during the voting period.

Key Features:

  • Two-phase voting: commit then reveal
  • Privacy-preserving vote submission
  • Protection against vote manipulation
Usage Example:
// Commit phase: submit hashed vote
ballot.commit_vote(hash(vote + secret));

// Wait for commit phase to end...

// Reveal phase: reveal actual vote
ballot.reveal_vote(vote, secret);

// Tally results after reveal phase
let results = ballot.tally();

Deployment

Deploy your Stylus contracts to Arbitrum testnet or mainnet.

Build Your Contract

cargo stylus build

Check WASM Size

cargo stylus check

Deploy to Arbitrum

cargo stylus deploy --private-key <YOUR_PRIVATE_KEY>

Security Note

Never commit private keys to version control. Use environment variables or hardware wallets for production deployments.

Resources

Additional learning materials and community resources.

Ready to build?

Start experimenting with Stylus contracts today. Clone the repo and deploy your first Rust-powered smart contract.