Skip to content

Install Cargo Stylus

🚀 Install Cargo CLI

1️⃣ Install Rust & Stylus CLI

Install Rust and then install the Stylus CLI tool:

cargo install --force cargo-stylus cargo-stylus-check

2️⃣ Add Wasm Target

rustup target add wasm32-unknown-unknown

3️⃣ Initialize & Deploy a Contract

RPC=http://localhost:8547
ARB_PREFUNDED_PK=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
cargo stylus new counterTest --minimal
cd counterTest
cargo stylus check --endpoint $RPC
cargo stylus deploy --endpoint $RPC --private-key $ARB_PREFUNDED_PK --no-verify

Cached Bytecode Uniqueness

Cached bytecode is unique - if several addresses share the same bytecode, it's cached only once. If you want to cache several bytecodes for testing, we suggest modifying the source code slightly.

Modify `src/lib.rs` before deployment, e.g., add a function:
```rust
/// Sets a number in storage to a user-specified value.
pub fn set_number_version_1(&mut self, new_number: U256) {
    self.number.set(new_number);
}
```

💰 Place a Bid using Cargo CLI

Basic Bid Placement

# Replace SC_ADD with your contract address
export SC_ADD=
cargo stylus cache bid $SC_ADD 0 --private-key $ARB_PREFUNDED_PK --endpoint $RPC

Cache Your Contract

After deploying your contract, you can cache it with:

# Cache your activated contract in ArbOS
cargo stylus cache bid $SC_ADD 0 --private-key $ARB_PREFUNDED_PK --endpoint $RPC

Additional Cache Commands

# Check cache status
cargo stylus cache status --endpoint $RPC

# Check specific contract cache status
cargo stylus cache status --endpoint $RPC --address $SC_ADD

# Get bid suggestions
cargo stylus cache suggest-bid $SC_ADD --endpoint $RPC

📚 Further Reading

For more information about the Stylus contract cache system:


Having troubles installing Stylus?

Check the Arbitrum Stylus CLI documentation for detailed installation instructions and troubleshooting.