Skip to content

Commit

Permalink
migrate readme's to #[storage] macro
Browse files Browse the repository at this point in the history
  • Loading branch information
qalisander committed Dec 11, 2024
1 parent 200c2c0 commit 3a7bc3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ openzeppelin-stylus = { git = "https://github.com/OpenZeppelin/rust-contracts-st
```

> [!NOTE]
> This library is designed to be `no_std`, which helps reduce wasm size. If you want your project to be `no_std` as well, ensure that your dependencies are not importing the standard library.
>You can achieve this by setting `default-features = false` for relevant dependencies in your `Cargo.toml`. For example:
> This library is designed to be `no_std`, which helps reduce wasm size. If you want your project to be `no_std` as
> well, ensure that your dependencies are not importing the standard library.
> You can achieve this by setting `default-features = false` for relevant dependencies in your `Cargo.toml`. For
> example:
>
> ```toml
> [dependencies]
Expand All @@ -58,20 +60,20 @@ openzeppelin-stylus = { git = "https://github.com/OpenZeppelin/rust-contracts-st
> }
> ```
>
> The library also works on an `std` environment, without the need to define a panic handler or making extra changes to your project.
> The library also works on an `std` environment, without the need to define a panic handler or making extra changes to
> your project.
Once defined as a dependency, use one of our pre-defined implementations by
importing them:
```rust
use stylus_sdk::prelude::*;
use openzeppelin_stylus::token::erc20::Erc20;
sol_storage! {
#[entrypoint]
struct Erc20Example {
#[borrow]
Erc20 erc20;
}
#[storage]
struct Erc20Example {
#[borrow]
pub erc20: Erc20,
}
#[public]
Expand All @@ -89,6 +91,7 @@ For more information on what this library will include in the future, see our
[roadmap].

[basic]: ./examples/basic

[roadmap]: https://github.com/OpenZeppelin/rust-contracts-stylus/milestone/2

## Contribute
Expand Down
10 changes: 4 additions & 6 deletions contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ importing them:
use stylus_sdk::prelude::*;
use openzeppelin_stylus::token::erc20::Erc20;
sol_storage! {
#[entrypoint]
struct MyContract {
#[borrow]
Erc20 erc20;
}
#[storage]
struct MyContract {
#[borrow]
pub erc20: Erc20,
}
#[public]
Expand Down

0 comments on commit 3a7bc3b

Please sign in to comment.