GULLY CHAINDocs

Stylus (Rust contracts)

On this page

Stylus is part of Arbitrum Nitro. It runs contracts compiled to WebAssembly next to the EVM, so you can write contracts in Rust (and other languages that compile to WASM). Stylus contracts and Solidity contracts can call each other, share the same state and use the same addresses and ABI.

Stylus is built into ArbOS from version 32. Gully Chain started at ArbOS 51, so Stylus is available on the testnet with nothing extra to enable. The ArbWasm precompile that activates Stylus programs is at 0x0000000000000000000000000000000000000071.

Note

Gully Labs has not yet published its own end-to-end Stylus example for this chain. The steps below are Arbitrum's standard cargo-stylus flow pointed at the Gully Chain RPC. If something fails that works on Arbitrum Sepolia, tell us at [email protected].

#Set up

You need Rust (via rustup), the WASM target, and cargo-stylus:

Shell
rustup target add wasm32-unknown-unknown
cargo install --force cargo-stylus

Docker is also needed for reproducible builds and for verification.

#Create a project

Shell
cargo stylus new counter
cd counter

This creates a small counter contract using the stylus-sdk crate.

#Check against Gully Chain

cargo stylus check builds the contract and asks the chain whether it would activate: size limits, allowed WASM features and the activation cost.

Shell
cargo stylus check --endpoint https://testnet-rpc.gullychain.xyz

#Deploy

Deploying a Stylus contract is two transactions: one stores the WASM, one activates it through ArbWasm. cargo stylus deploy sends both. You need test ETH on Gully Chain for gas and the activation fee (see Quickstart).

Shell
# estimate first
cargo stylus deploy \
  --endpoint https://testnet-rpc.gullychain.xyz \
  --private-key-path ./key.txt \
  --estimate-gas

# then deploy and activate
cargo stylus deploy \
  --endpoint https://testnet-rpc.gullychain.xyz \
  --private-key-path ./key.txt

Keep the key file outside the repo, and use a throwaway testnet key. The command prints the contract address; look it up on the explorer.

#Call it

A Stylus contract has a normal Solidity ABI. Export it and call the contract with any EVM tool:

Shell
cargo stylus export-abi

cast call <address> "number()(uint256)" --rpc-url https://testnet-rpc.gullychain.xyz
cast send <address> "increment()" --rpc-url https://testnet-rpc.gullychain.xyz --account dev

#Things to know

  • Activation is per chain. A program activated on Arbitrum Sepolia is not activated on Gully Chain; deploy it here.
  • Reactivation. Activated programs expire after a period set by ArbOS (one year by default) and after some ArbOS upgrades, and then need cargo stylus activate again. Follow Arbitrum's Stylus docs for the current rules.
  • The same Arbitrum rules apply. block.number and gas behave as described on the Network reference.