Expand description
Module for Miden SDK macros
§How to use WIT generation.
- Add
#[component]on youimpl MyAccountType {. - Add
#[export_type]on every defined type that is used in the public(exported) method signature.
Example:
ⓘ
#[export_type]
pub struct StructA {
pub foo: Word,
pub asset: Asset,
}
#[export_type]
pub struct StructB {
pub bar: Felt,
pub baz: Felt,
}
#[component]
struct MyAccount;
#[component]
impl MyAccount {
pub fn foo(&self, a: StructA) -> StructB {
...
}
}§Escape hatch (disable WIT generation)
in a small fraction of the cases where the WIT generation is not possible (think a type defined only in an external WIT file) or not desirable the WIT generation can be disabled:
To disable WIT interface generation:
- Don’t use
#[component]attribute macro in theimpl MyAccountTypesection;
To use manually crafted WIT interface:
- Put the WIT file in the
witfolder; - call
miden::generate!();andbindings::export!(MyAccountType); - implement
impl Guest for MyAccountType;
Macros§
- generate
- Generate bindings for an input WIT document.
Attribute Macros§
- component
- Generates the WIT interface and storage metadata.
- export_
type - Generates an equvalent type in the WIT interface. Required for every type mentioned in the public methods of an account component.
- note
- Marks a type/impl as a note script definition.
- note_
script - Marks a method as the note script entrypoint (
#[note_script]). - tx_
script - Marks the function as a transaction script