### Scaffold-Stylus Project Setup Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Clones the Scaffold-Stylus repository, installs project dependencies using Yarn, and updates Git submodules, which is necessary for running the Nitro dev node. ```bash git clone https://github.com/Arb-Stylus/scaffold-stylus.git cd scaffold-stylus yarn install git submodule update --init --recursive ``` -------------------------------- ### Repository Cloning and Setup Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/nitro-devnode/README.md These bash commands guide the user through cloning the Nitro devnode repository and navigating into the project directory to prepare for running the development node. ```bash git clone https://github.com/OffchainLabs/nitro-devnode.git cd nitro-devnode ``` -------------------------------- ### Start Next.js Application Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Launches the Next.js frontend application for Scaffold-Stylus. The application can then be accessed at `http://localhost:3000` and used to interact with deployed smart contracts. ```bash yarn start ``` -------------------------------- ### Check Stylus Installation Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Command to verify if the 'stylus' tool has been successfully installed and is accessible in the system's PATH. ```Bash cargo stylus --version ``` -------------------------------- ### Install Stylus CLI Tools Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Installs the Stylus CLI tools, including `cargo-stylus` and `cargo-stylus-check`, which are essential for developing and interacting with Stylus contracts. It also sets up the Rust toolchain and build target. ```bash cargo install --force cargo-stylus cargo-stylus-check rustup default 1.87 rustup target add wasm32-unknown-unknown --toolchain 1.87 ``` -------------------------------- ### Stylus Contract Constructor Example Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Example of a Stylus contract constructor function, which should be left blank if no constructor logic is needed, especially for Orbit chains. ```rust [#constructor] pub fn constructor(&mut self) ``` -------------------------------- ### Run Local Arbitrum Network Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Starts a local Stylus-compatible development network using the Nitro dev node. This provides a local environment for testing dApps without deploying to a public testnet. ```bash yarn chain ``` -------------------------------- ### Install pkg-config and libssl-dev for Stylus Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Command to install necessary packages for the 'stylus' tool on Debian-based systems. Ensures that 'pkg-config' and 'libssl-dev' are installed, which are often dependencies for Rust-based command-line tools. ```Bash sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev ``` -------------------------------- ### Initialize Stylus Contract Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Example Rust function for initializing a Stylus contract with a number, including a check to prevent re-initialization. Also shows the command-line interface for calling the initialize function. ```Rust pub fn initialize(&mut self, initial_number: U256) { if !self.is_initialized.get() { self.number.set(initial_number); self.is_initialized.set(true); } else { panic!("Counter already initialized"); } } ``` ```Bash cast --rpc-url --private-key [deployed-contract-address] "initialize(uint256)" ``` -------------------------------- ### Running the Nitro Dev Node Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/nitro-devnode/README.md This bash command executes the `run-dev-node.sh` script, which starts a Nitro dev node in a Docker container, deploys the Stylus Cache Manager contract, and registers it as a WASM cache manager. ```bash ./run-dev-node.sh ``` -------------------------------- ### Deploy Test Contract Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Deploys a test smart contract to the locally running network. The contract is located in `packages/stylus/your-contract/src` and the deployment process is managed by a script in `packages/stylus/scripts`. ```bash yarn deploy ``` -------------------------------- ### Deploying Contracts to Other Networks Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Command to deploy contracts to a specified network after configuring environment variables and frontend settings. ```bash yarn deploy --network ``` -------------------------------- ### Convert Line Endings and Make Executable Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Instructions for converting Windows CRLF line endings to Unix LF line endings using 'dos2unix' and making a shell script executable. ```Bash sudo apt install dos2unix dos2unix run-dev-node.sh chmod +x run-dev-node.sh ``` -------------------------------- ### Create New Stylus Contract Module Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Generates a new smart contract module within the Scaffold-Stylus project. This command scaffolds the necessary files and structure for a new contract, located in `packages/stylus/`. ```bash yarn new-module ``` -------------------------------- ### Frontend Configuration for Target Networks Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Update the frontend configuration to include target networks for contract deployment. This ensures the frontend connects to the correct network and generates the appropriate ABI. ```typescript import * as chains from "viem/chains"; // ... targetNetworks: [chains.arbitrumSepolia], ``` -------------------------------- ### Environment Variable Configuration for Deployment Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Configure RPC endpoints and private keys for deploying contracts to specific networks by setting environment variables. This includes RPC_URL and PRIVATE_KEY for the target network. ```env RPC_URL_SEPOLIA=https://your-network-rpc-url PRIVATE_KEY_SEPOLIA=your_private_key_here ACCOUNT_ADDRESS_SEPOLIA=your_account_address_here ``` -------------------------------- ### Run Smart Contract Tests Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Executes automated tests for the smart contracts developed within the Scaffold-Stylus project. This ensures the contracts function as expected. ```bash yarn stylus:test ``` -------------------------------- ### Restart Local Development Environment Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Command to restart the local development environment, typically used when facing issues with ABI generation. This involves stopping and restarting Docker containers. ```Bash yarn run dev ``` -------------------------------- ### Deploy Custom Stylus Contract Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Deploys a custom smart contract using the `deploy.ts` script. This command allows specifying deployment options such as the target network, gas estimation, and maximum transaction fees. ```bash yarn deploy [--network ] [--estimate-gas] [--max-fee=] ``` -------------------------------- ### Run Shell Script in WSL Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Command to execute a shell script within the Windows Subsystem for Linux (WSL) environment after ensuring correct line endings and execute permissions. ```Bash bash run-dev-node.sh ``` -------------------------------- ### Export ABI with Cargo Stylus Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Alternative command to export the ABI using Cargo, potentially resolving issues with the standard 'cargo stylus export-abi' command. ```Bash cargo run --manifest-path=Cargo.toml --features export-abi ``` -------------------------------- ### Local Stylus Contract Verification Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Enable local verification during contract deployment by setting `verify: true`. This process checks bytecode against source code and ensures reproducibility. ```typescript await deployStylusContract({ contract: "your-contract", verify: true, ...deployOptions, }); ``` -------------------------------- ### Change Target Directory Ownership Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/readme.md Command to change the ownership of the 'target' directory to the current user, which can resolve 'access denied' errors during build or ABI generation processes. ```Bash sudo chown -R $USER:$USER target ``` -------------------------------- ### Become Chain Owner Command Source: https://github.com/arb-stylus/scaffold-stylus/blob/main/nitro-devnode/README.md This bash command uses `cast send` to call the `becomeChainOwner()` function on the ArbDebug precompile. It assumes ownership of the chain for the specified development account, which is necessary for registering the Cache Manager contract. ```bash cast send 0x00000000000000000000000000000000000000FF "becomeChainOwner()" --private-key 0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 --rpc-url http://127.0.0.1:8547 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.