This repository contains a collection of simple Arbitrum Stylus smart contract examples written in Rust. They demonstrate how to build various systems, from basic counters to complex cross-contract logic with Solidity.
- counter: A basic Rust contract that stores and modifies a number.
- internal-calls: Shows how a Rust contract can call its own internal functions.
- stylus-calls-solidity: A Stylus caller contract talking to a Solidity calculator.
- solidity-calls-stylus: A Solidity caller talking to a Stylus counter.
- stylus-deep-logic: A more complex Rust tracker sending data back and forth to a Solidity verifier.
- auction-with-stylus-token: An implementation of an ERC-20 token in Stylus used inside a Solidity Auction contract.
Each example folder comes with its own deploy.sh script that automates the deployment process. Generally, you can navigate into any folder and run:
chmod +x deploy.sh
./deploy.shFor running the deployment scripts and tracing, make sure you have the following installed:
solc(Solidity Compiler)castandforge(Foundry tools)cargo stylus(Installation guide)
The examples require a local Nitro dev node running on http://localhost:8547. Start one using Docker:
docker run -it --rm --name nitro-dev -p 8547:8547 offchainlabs/nitro-node:v3.9.5-rc.2-762ee40 --dev --http.addr 0.0.0.0 --http.api=net,web3,eth,arb,arbdebug,debugFor examples that demonstrate interoperability between Stylus and Solidity contracts (e.g., stylus-deep-logic, stylus-calls-solidity, solidity-calls-stylus, auction-with-stylus-token), you will also need to run soldb.
- Repository: walnuthq/soldb
- Start the bridge by running
soldb bridgein a separate terminal before executing your tests or traces.
Explore each subfolder's README.md for more details!