The Stylus Rust SDK (v0.10.2) lets you write Solidity ABI-equivalent smart contracts in Rust, compiled to WebAssembly and executed on Arbitrum chains. For a conceptual introduction, see Stylus: A Gentle Introduction. To deploy your first contract, see the Quickstart.
The SDK is built on Alloy, the standard Rust Ethereum primitive library. Because both share the same types, Stylus contracts are compatible with the broader Rust Ethereum ecosystem.
The SDK has been audited by OpenZeppelin:
All reports are listed on the security audit reports page.
SDK architecture
The SDK is a Cargo workspace of six crates. Most developers only interact with stylus-sdk and cargo-stylus directly — the others are internal dependencies.
| Crate | Purpose |
|---|
stylus-sdk | Main SDK — storage types, ABI encoding, call abstractions, crypto, deploy, and the prelude module |
stylus-proc | Procedural macros: #[entrypoint], #[public], #[constructor], sol_storage!, sol_interface! |
stylus-core | Core trait definitions (Host, HostAccess) shared across the workspace |
stylus-test | Testing framework with TestVM for unit-testing contracts without a blockchain |
stylus-tools | Deployment, activation, verification, and caching operations (used by cargo-stylus) |
cargo-stylus | CLI tool for building, deploying, debugging, and managing Stylus contracts |
Requirements: Rust 1.91.0 or later (pinned in rust-toolchain.toml). Contracts compile to the wasm32-unknown-unknown target.
Feature flags
The stylus-sdk crate exposes these Cargo features:
| Feature | Default | Description |
|---|
mini-alloc | Yes | Uses an efficient WASM allocator. Disable to use a custom global allocator |
export-abi | No | Enables ABI export via cargo stylus export-abi. Adds debug and uses tiny-keccak |
debug | No | Enables the console! debugging macro for printing to the Blockchain Explorer's trace view |
hostio | No | Makes the low-level hostio module public for direct host I/O access |
stylus-test | No | Enables the testing module with TestVM for writing unit tests without deploying |
reentrant | No | Enables reentrancy support across stylus-proc, stylus-core, and stylus-test |
Public modules
The stylus-sdk crate re-exports these modules from its root:
| Module | Description |
|---|
abi | ABI encoding and decoding types |
call | Cross-contract call abstractions (static calls, delegate calls, value transfers) |
crypto | Cryptographic utilities (keccak256) |
debug | The console! macro for trace-level logging (requires the debug feature) |
deploy | Contract deployment via RawDeploy |
host | VM host interface (self.vm()) for accessing block context, message data, and storage |
hostio | Low-level host I/O FFI bindings (requires the hostio feature to be public) |
methods | Method routing utilities |
prelude | Common imports — re-exports the types most contracts need |
storage | Persistent storage types (StorageU256, StorageAddress, StorageMap, StorageVec, etc.) |
Documentation index
Fundamentals
| Article | Description |
|---|
| Structure of a contract | Project layout, the #[entrypoint] macro, and #[public] methods |
| Global variables and functions | Access blockchain context through self.vm() — message sender, block info, and crypto functions |
| Contracts | Storage definition, method declarations, and the contract lifecycle |
| Writing tests | Unit test contracts with TestVM without deploying to a blockchain |
Data types
| Article | Description |
|---|
| Primitives | Rust primitives (bool, integers, addresses) with automatic ABI encoding and Solidity type mappings |
| Compound types | Arrays, vectors, tuples, and custom structs |
| Storage | Persistent contract state using storage types and the sol_storage! macro |
| Conversions between types | Converting between Rust types and Solidity-compatible types |
Advanced topics
Using the CLI
WASM concepts
| Article | Description |
|---|
| WebAssembly | How WASM compilation, deployment, and execution work in Arbitrum Nitro |
| VM differences | Behavioral differences between Stylus WASM execution and traditional EVM |
| Activation | The contract activation process required before a Stylus contract can execute |
| Caching strategy | Leveraging the WASM caching system for contract performance |
Troubleshooting
| Article | Description |
|---|
| Troubleshooting | Common issues when building and deploying Stylus contracts |
External references