OpenZeppelin Contracts for Stylus
Features
-
✨ Security-first contracts ported from
openzeppelin-contracts
. -
📦 Written in Rust with full
no_std
support. -
🧪 Tested with both unit and integration tests.
-
🚧 Actively developed.
Quick Start
Add the dependency to your Cargo.toml
:
[dependencies]
openzeppelin-stylus = "=0.2.0"
Enable the ABI export feature:
[features]
export-abi = ["openzeppelin-stylus/export-abi"]
Usage Example
A minimal ERC-20 implementation using the library:
use openzeppelin_stylus::token::erc20::{self, Erc20, IErc20};
use stylus_sdk::{
alloy_primitives::{Address, U256},
prelude::*,
};
#[entrypoint]
#[storage]
struct Erc20Example {
erc20: Erc20,
}
#[public]
#[implements(IErc20<Error = erc20::Error>)]
impl Erc20Example {}
#[public]
impl IErc20 for Erc20Example {
// ERC-20 logic implementation...
}
Explore more examples in the examples
directory.
Compatibility
This library is designed to work with no_std
. To keep your contracts compatible, disable default features for any dependencies that pull in the standard library:
[dependencies]
alloy-primitives = { version = "=0.8.20", default-features = false }
stylus-sdk = "=0.9.0"
Roadmap & Contributing
See what’s planned or in development in our roadmap.
Interested in contributing? Read the contribution guide.
Security
While this library is under active development, security remains a top priority. For past audits and security reports, see the audits
directory.
License
Released under the MIT License.