Loading...
Loading...
Set up a Stylus smart contract project with OpenZeppelin Contracts for Stylus on Arbitrum. Use when users need to: (1) install Rust toolchain and WASM target for Stylus, (2) create a new Cargo Stylus project, (3) add OpenZeppelin Stylus dependencies to Cargo.toml, or (4) understand Stylus import conventions and storage patterns for OpenZeppelin.
npx skill4agent add openzeppelin/openzeppelin-skills setup-stylus-contractscurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknowncargo install --force cargo-styluscargo stylus new my_projectA Rust nightly toolchain is required. The project should include aspecifying the nightly channel,rust-toolchain.tomlcomponent, andrust-srctarget. Check the rust-contracts-stylus repo for the current recommended nightly date.wasm32-unknown-unknown
Cargo.toml[dependencies]
openzeppelin-stylus = "=<VERSION>"export-abi[features]
export-abi = ["openzeppelin-stylus/export-abi"][lib]
crate-type = ["lib", "cdylib"]openzeppelin_stylususe openzeppelin_stylus::token::erc20::{Erc20, IErc20};
use openzeppelin_stylus::access::ownable::{Ownable, IOwnable};
use openzeppelin_stylus::utils::pausable::{Pausable, IPausable};
use openzeppelin_stylus::utils::introspection::erc165::IErc165;#[storage]#[entrypoint]#[entrypoint]
#[storage]
struct MyToken {
erc20: Erc20,
ownable: Ownable,
}#[public]#[implements(...)]#[public]
#[implements(IErc20<Error = erc20::Error>, IOwnable<Error = ownable::Error>)]
impl MyToken {}
#[public]
impl IErc20 for MyToken {
type Error = erc20::Error;
// delegate to self.erc20 ...
}accessfinanceproxytokenutilscargo stylus checkcargo stylus export-abicargo stylus deploy --endpoint="<RPC_URL>" --private-key-path="<KEY_FILE>"