Crate stylus_proc

Crate stylus_proc 

Source
Expand description

Procedural macros for The Stylus SDK.

You can import these via

use stylus_sdk::prelude::*;

For a guided exploration of the features, please see the comprehensive Feature Overview.

Macros§

sol_interface
Facilitates calls to other contracts.
sol_storage
The types in #[storage] are laid out in the EVM state trie exactly as they are in Solidity. This means that the fields of a struct definition will map to the same storage slots as they would in EVM programming languages. Hence, it is often nice to define types using Solidity syntax, which makes this guarantee easier to see.

Attribute Macros§

entrypoint
Defines the entrypoint, which is where Stylus execution begins. Without it the contract will fail to pass cargo stylus check. Most commonly this macro is used to annotate the top level storage struct.
public
Just as with storage, Stylus SDK methods are Solidity ABI-equivalent. This means that contracts written in different programming languages are fully interoperable. You can even automatically export your Rust contract as a Solidity interface so that others can add it to their Solidity projects.
storage
Allows a Rust struct to be used in persistent storage.

Derive Macros§

AbiType
Implements the AbiType for arbitrary structs, allowing them to be used in external method return types and parameters. This derive is intended to be used within the alloy_sol_types::sol macro.
Erase
Some StorageType values implement Erase, which provides an erase() method for clearing state. The Stylus SDK implements Erase for all primitives, and for vectors of primitives, but not for maps. This is because a Solidity mapping does not provide iteration, and so it’s generally impossible to know which slots to clear.
SolidityError
Allows an error enum to be used in method signatures.