rootchain-macros
Procedural macros for the RootChain smart contract framework.
This crate provides the #[rootchain_contract] derive macro, which eliminates the boilerplate required to write smart contracts targeting the RootChain WASM virtual machine.
What's Inside
| Macro | Description |
|---|---|
#[rootchain_contract] |
Generates the WASM entry point, ABI dispatch table, and input/output glue code for a smart contract struct |
Installation
This crate is typically used via rootchain-std, which re-exports it. You rarely need to add it directly.
# Use via rootchain-std (recommended):
[]
= { = "1.0.2", = false }
# Or use directly:
[]
= "1.0.2"
Usage
The #[rootchain_contract] macro is applied to an impl block and generates a WASM-compatible dispatch function. Your contract methods become callable ABI endpoints.
use *;
;
How It Works
The macro generates:
- A
#[no_mangle] pub extern "C" fn apply(method_id: u32)entry point. - A dispatch table that routes
method_idto the correct method on your struct. - Automatic reading of WASM host input and writing of output.
License
MIT — See LICENSE for details.