rootchain-macros 1.0.2

Procedural macros for the RootChain ecosystem, providing syntax extensions for smart contract development.
Documentation
# rootchain-macros

[![Crates.io](https://img.shields.io/crates/v/rootchain-macros.svg)](https://crates.io/crates/rootchain-macros)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../../LICENSE)

> **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.

```toml
# Use via rootchain-std (recommended):
[dependencies]
rootchain-std = { version = "1.0.2", default-features = false }

# Or use directly:
[dependencies]
rootchain-macros = "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.

```rust
use rootchain_std::prelude::*;

pub struct MyToken;

#[rootchain_contract]
impl MyToken {
    // Method 0: Initialize the contract
    pub fn init(&mut self, _input: &[u8]) {
        // Set initial state
    }

    // Method 1: A callable contract method
    pub fn transfer(&mut self, input: &[u8]) {
        // Deserialize input, apply state changes
    }
}
```

### How It Works

The macro generates:
1. A `#[no_mangle] pub extern "C" fn apply(method_id: u32)` entry point.
2. A dispatch table that routes `method_id` to the correct method on your struct.
3. Automatic reading of WASM host input and writing of output.

---

## License

MIT — See [LICENSE](../../LICENSE) for details.