Module storage

Source
Expand description

Solidity compatible storage types and persistent storage access.

The Stylus node software is composed of two, fully-composable virtual machines.

  • The Stylus VM, which compiles WASM contracts built with SDKs like this one.
  • The Ethereum Virtual Machine, which interprets EVM bytecode from languages like Solidity and Vyper.

Though these two VMs differ in execution, they are backed by the same EVM State Trie. This means that Stylus contracts have access to the same, key-value based persistent storage familiar to Solidity devs.

Because this resource is foreign to Rust, this module provides standard types and traits for accessing state when writing programs. To protect the user, the Stylus SDK safeguards storage access by leveraging Rust’s borrow checker. It should never be possible to alias Storage without unsafe Rust, eliminating entire classes of errors at compile time.

For a walkthrough of this module’s features, please see The Feature Overview.

Structs§

StorageAddress
Accessor for a storage-backed Address.
StorageArray
Accessor for a storage-backed array.
StorageBlockHash
Accessor for a storage-backed BlockHash.
StorageBlockNumber
Accessor for a storage-backed BlockNumber.
StorageBool
Accessor for a storage-backed bool.
StorageBytes
Accessor for storage-backed bytes.
StorageCache
Global accessor to persistent storage that relies on VM-level caching.
StorageFixedBytes
Accessor for a storage-backed FixedBytes.
StorageGuard
Binds a storage accessor to a lifetime to prevent aliasing. Because this type doesn’t implement DerefMut, mutable methods on the accessor aren’t available. For a mutable accessor, see StorageGuardMut.
StorageGuardMut
Binds a storage accessor to a lifetime to prevent aliasing.
StorageMap
Accessor for a storage-backed map.
StorageSigned
Accessor for a storage-backed Signed.
StorageString
Accessor for storage-backed bytes
StorageUint
Accessor for a storage-backed alloy_primitives::Uint.
StorageVec
Accessor for a storage-backed vector.

Traits§

Erase
Trait for accessors that can be used to completely erase their underlying value. Note that some collections, like StorageMap, don’t implement this trait.
GlobalStorage
Trait for managing access to persistent storage. Implemented by the StorageCache type.
SimpleStorageType
Trait for simple accessors that store no more than their wrapped value. The type’s representation must be entirely inline, or storage leaks become possible. Note: it is a logic error if erasure does anything more than writing the zero-value.
StorageKey
Trait that allows types to be the key of a StorageMap.
StorageType
Accessor trait that lets a type be used in persistent storage. Users can implement this trait to add novel data structures to their contract definitions. The Stylus SDK by default provides only solidity types, which are represented the same way.

Type Aliases§

StorageB8
Accessor for a storage-backed alloy_primitives::aliases::B8.
StorageB16
Accessor for a storage-backed alloy_primitives::aliases::B16.
StorageB32
Accessor for a storage-backed alloy_primitives::aliases::B32.
StorageB64
Accessor for a storage-backed alloy_primitives::aliases::B64.
StorageB96
Accessor for a storage-backed alloy_primitives::aliases::B96.
StorageB128
Accessor for a storage-backed alloy_primitives::aliases::B128.
StorageB160
Accessor for a storage-backed [alloy_primitives::aliases::B160].
StorageB192
Accessor for a storage-backed alloy_primitives::aliases::B192.
StorageB224
Accessor for a storage-backed alloy_primitives::aliases::B224.
StorageB256
Accessor for a storage-backed alloy_primitives::aliases::B256.
StorageI8
Accessor for a storage-backed alloy_primitives::aliases::I8.
StorageI16
Accessor for a storage-backed alloy_primitives::aliases::I16.
StorageI32
Accessor for a storage-backed alloy_primitives::aliases::I32.
StorageI64
Accessor for a storage-backed alloy_primitives::aliases::I64.
StorageI128
Accessor for a storage-backed alloy_primitives::aliases::I128.
StorageI160
Accessor for a storage-backed alloy_primitives::aliases::I160.
StorageI192
Accessor for a storage-backed alloy_primitives::aliases::I192.
StorageI256
Accessor for a storage-backed alloy_primitives::aliases::I256.
StorageU8
Accessor for a storage-backed alloy_primitives::aliases::U8.
StorageU16
Accessor for a storage-backed alloy_primitives::aliases::U16.
StorageU32
Accessor for a storage-backed alloy_primitives::aliases::U32.
StorageU64
Accessor for a storage-backed alloy_primitives::aliases::U64.
StorageU128
Accessor for a storage-backed alloy_primitives::aliases::U128.
StorageU160
Accessor for a storage-backed alloy_primitives::aliases::U160.
StorageU192
Accessor for a storage-backed alloy_primitives::aliases::U192.
StorageU256
Accessor for a storage-backed alloy_primitives::aliases::U256.