## Arbitrum Stylus cheatsheet ## Prerequisites Required tools: - IDE (VSCode recommended) - Docker - Rust toolchain - cargo-stylus - Deployment wallet with funds - Access to Arbitrum Sepolia RPC ## Installation ### 1. Install Rust ```bash # Install Rust toolchain curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Add WASM target rustup target add wasm32-unknown-unknown ``` ### 2. Install Cargo Stylus ```bash # Install specific version for compatibility cargo install --force cargo-stylus --version 0.5.3 ``` ### 3. Install Docker Docker is required for reproducible builds. Install from: - Linux: Use package manager - macOS: [Docker Desktop for Mac](https://docs.docker.com/desktop/install/mac-install/) - Windows: [Docker Desktop for Windows](https://docs.docker.com/desktop/install/windows-install/) ## Project Setup ### Create New Project ```bash # Create minimal project cargo stylus new my_project --minimal # Create project with example cargo stylus new my_project ``` ### Project Structure ``` my_project/ ├── Cargo.toml # Project dependencies ├── rust-toolchain.toml # Rust version config └── src/ ├── lib.rs # Contract implementation └── main.rs # Entry point ``` ## Development Workflow ### 1. Contract Verification ```bash # Verify contract can be deployed cargo stylus check ``` Expected output will show: - Contract size - WASM size - Project metadata hash - Files used for deployment hash ### 3. Gas Estimation ```bash # Estimate deployment costs cargo stylus deploy \ --endpoint="https://sepolia-rollup.arbitrum.io/rpc" \ --private-key="your-private-key" \ --estimate-gas ``` ## Deployment ### 1. Deploy Contract ```bash # Deploy to Arbitrum Sepolia cargo stylus deploy \ --endpoint="https://sepolia-rollup.arbitrum.io/rpc" \ --private-key="your-private-key" ``` ### 2. Export Contract ABI ```bash # Generate Solidity interface cargo stylus export-abi ``` ## Contract Verification ### 1. On-chain Verification ```bash # Verify deployed contract cargo stylus verify \ --deployment-tx="YOUR_DEPLOYMENT_TX_HASH" \ --endpoint="https://sepolia-rollup.arbitrum.io/rpc" ``` ### 2. Arbiscan Verification #### Quick Steps 1. Visit [Arbiscan Verify Contract](https://arbiscan.io/verifyContract) or navigate through contract page 2. Fill required fields: - Contract Address - Compiler Type: "Stylus" - Compiler Version: Match your `cargo-stylus` version - License Type: Select appropriate 3. Submit code: - Upload source code to a public Github repository. - Use "Fetch from Git" 4. Click "Verify and Publish" #### View Verified Contracts - [Arbitrum One Verified Stylus Contracts](https://arbiscan.io/find-similar-contracts?a=0x) - [Arbitrum Sepolia Verified Stylus Contracts](https://sepolia.arbiscan.io/find-similar-contracts?a=0x) ## Contract Integration ### 1. Generate ABI ```bash cargo stylus export-abi ``` ### 2. Interface Example ```solidity interface ICounter { function number() external view returns (uint256); function setNumber(uint256 new_number) external; function increment() external; } ``` # Resources ### Official Documentation - [Arbitrum Stylus Documentation](https://docs.arbitrum.io/stylus/stylus-quickstart) - [Stylus by Example](https://stylus-by-example.org) - [Valid WASM Guide](https://github.com/OffchainLabs/cargo-stylus/blob/main/main/VALID_WASM.md) ### Development Tools - [cargo-stylus Repository](https://github.com/OffchainLabs/cargo-stylus) ### Community Resources - [Arbitrum Stylus Telegram group](https://t.me/arbitrum_stylus) - [Arbitrum Discord](https://discord.com/invite/arbitrum)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up