aztec-nr - noir_aztec::macros::storage

Function storage

pub comptime fn storage(s: TypeDefinition) -> Quoted

This function

  • marks the contract as having storage, so that macros::utils::module_has_storage will return true,
  • marks the struct s as the one describing the storage layout of a contract,
  • generates an impl block for the storage struct with an init function (call to init is then injected at the beginning of every #[external(...)] and #[internal] contract function and the storage is then available as self.storage),
  • creates a StorageLayout struct that is is exposed via the abi(storage) macro in the contract artifact.

Only a single struct in the entire contract should have this macro (or storage_no_init) applied to it, and the struct has to be called 'Storage'.