🧪 An open-source, up-to-date toolkit for building decentralized applications (dapps) on the Arbitrum blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts.
⚙️ Built using Rust, NextJS, RainbowKit, Stylus, Wagmi, Viem, and TypeScript.
- ✅ Contract Hot Reload: Your frontend auto-adapts to your smart contract as you edit it.
- 🪝 Custom hooks: Collection of React hooks wrapped around wagmi to simplify interactions with smart contracts with TypeScript autocompletion.
- 🧱 Components: Collection of common web3 components to quickly build your frontend.
- 🔥 Burner Wallet & Local Faucet: Quickly test your application with a burner wallet and local faucet.
- 🔐 Integration with Wallet Providers: Connect to different wallet providers and interact with the Arbitrum network.
Before you begin, you need to install the following tools:
Note: Windows Compatibility
Scaffold-Stylus currently does not support Windows natively. If you're using Windows, we recommend:
- Use WSL (Windows Subsystem for Linux) - Install WSL2 and run Scaffold-Stylus within the Linux environment
- Switch to Linux or macOS - For the best development experience
For WSL setup, follow the Microsoft WSL installation guide.
To get started with Scaffold-Stylus, follow the steps below:
If you prefer a one-liner, install via stylusup (recommended):
Tool for installing all the Stylus essentials for development. Stylusup will install the latest stable versions of:
- Rust (if not present) to provide the core programming environment.
- cargo-stylus (latest version) a tool for creating and managing Stylus projects.
- Adding WebAssembly support to compile Rust code for blockchain environments.
- Optionally collecting and sending telemetry data to track installation statistics.
curl -s https://stylusup.sh/install.sh | shcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shCheck the Rust installation guide for more information.
Then install the Stylus CLI tools:
cargo install --force cargo-stylus cargo-stylus-checkPrerequisite:
cargo-stylusversion^0.6.1rustcversion match withpackages/stylus/your-contract/rust-toolchain.toml
Set default toolchain match rust-toolchain.toml and add the wasm32-unknown-unknown build target to your Rust compiler:
rustup default 1.89
rustup target add wasm32-unknown-unknown --toolchain 1.89You should now have it available as a Cargo subcommand:
cargo stylus --helpUse the interactive setup to scaffold a new project:
npx create-stylus@latestThen navigate into your project directory:
cd <project-name>
yarn install
# Initialize submodules (required for Nitro dev node)
git submodule update --init --recursivegit clone https://github.com/Arb-Stylus/scaffold-stylus.git
cd scaffold-stylus
yarn install
# Initialize submodules (required for Nitro dev node)
git submodule update --init --recursiveIn your first terminal:
yarn chainThis command starts a local Stylus-compatible network using the Nitro dev node script (./nitro-devnode/run-dev-node.sh). The network runs on your local machine and can be used for testing and development. You can customize the Nitro dev node configuration in the nitro-devnode submodule.
In your second terminal:
yarn deployThis command deploys a test smart contract to the local network. The contract is located in packages/stylus/your-contract/src and can be modified to suit your needs. The yarn deploy command uses the deploy script located in packages/stylus/scripts to deploy the contract to the network. You can also customize the deploy script .
In your third terminal:
yarn startVisit your app at: http://localhost:3000. You can interact with your smart contract using the Debug Contracts page, which provides a user-friendly interface for testing your contract's functions and viewing its state.
yarn stylus:test- Edit your smart contract
lib.rsinpackages/stylus/your-contract/src - Edit your frontend in
packages/nextjs/app - Edit your deployment scripts in
packages/stylus/scripts
Scaffold-Stylus enables you to create and deploy multiple contracts within a single project. Follow the steps below to create and deploy your own contracts.
Use the following command to create a new contract and customize it as needed:
yarn new-module <contract-name>The generated contract will be located in packages/stylus/<contract-name>.
Before deploying, it's recommended to validate your contract size using cargo stylus check:
cd packages/stylus/<contract-name>
cargo stylus checkThis command performs several important checks:
- Contract size validation: Ensures your contract doesn't exceed size limitations
- WASM compilation: Verifies your Rust code compiles to WebAssembly
- Deployment hash computation: Calculates the deployment hash
- WASM data fee estimation: Estimates the cost of deploying your contract
Contract Size Indicators:
- 🔴 Red indicator: Contract size exceeds limitations - DO NOT DEPLOY
- 🟡 Yellow/🟢 Green indicator: Contract size within acceptable limits - OK to deploy
Important: When using constructors, error logs from constructor execution may not be visible. Consider using
initialize()functions instead for better error visibility.
yarn deploy [...options]This command runs the deploy.ts script located in packages/stylus/scripts. You can customize this script with your deployment logic.
Available Options:
--network <network>: Specify which network to deploy to--estimate-gas: Only perform gas estimation without deploying--max-fee=<maxFee>: Set maximum fee per gas in gwei
Note: Deployment information is automatically saved in packages/stylus/deployments by default.
To deploy your contracts to other networks (other than the default local Nitro dev node), you'll need to configure your RPC endpoint and wallet credentials.
-
Set the RPC URL
Configure your target network's RPC endpoint using the proper
RPC_URL_<network>environment variable. You can set this in your shell or create a.envfile (see.env.examplefor reference):RPC_URL_SEPOLIA=https://your-network-rpc-url
Note: If RPC URL is not provided, system will use default public RPC URL from that network
-
Set the Private Key
For real deployments, you must provide your own wallet's private key. Set the
PRIVATE_KEY_<network>environment variable:PRIVATE_KEY_SEPOLIA=your_private_key_here
Security Note: A development key is used by default when running the Nitro dev node locally, but for external deployments, you must provide your own private key.
-
Set the Account Address
Set the
ACCOUNT_ADDRESS_<network>ACCOUNT_ADDRESS_SEPOLIA=your_account_address_here
-
Update Frontend Configuration
Open
packages/nextjs/scaffold.config.tsand update thetargetNetworksarray to include your target chain. This ensures your frontend connects to the correct network and generates the proper ABI indeployedContracts.ts:import * as chains from "./utils/scaffold-stylus/supportedChains"; // ... targetNetworks: [chains.arbitrumSepolia],
For Arbitrum testnets, you may need testnet ETH to deploy contracts. You can obtain testnet tokens from these faucets:
This template supports Arbitrum networks only. You can test which networks are available and their RPC URLs:
yarn info:networksThis will show you all supported networks and their corresponding RPC endpoints.
Once configured, deploy to your target network:
yarn deploy --network <network>Important Security Notes:
- The values in
.env.exampleprovide a template for required environment variables - Always keep your private key secure and never commit it to version control
- Consider using environment variable management tools for production deployments
Visit our Deploy to Orbit chain documentation for detailed guide
Visit our Verify section
Visit our Troubleshooting section
Visit our docs to learn how to start building with Scaffold-Stylus.
To learn more about its features, check out our website.
We welcome contributions to Scaffold-Stylus!
Please see CONTRIBUTING.md for more information and guidelines for contributing to Scaffold-Stylus.
