# Supporting noir macros

**URL:** https://forum.aztec.network/t/supporting-noir-macros/344
**Category:** Noir
**Tags:** noir
**Created:** [May 9, 2023, 10:44am UTC](https://forum.aztec.network/t/supporting-noir-macros/344 "2023-05-09T10:44:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alvaro](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@alvaro](https://forum.aztec.network/u/alvaro)
#### Post date: [May 9, 2023, 10:44am UTC](https://forum.aztec.network/t/supporting-noir-macros/344/1 "2023-05-09T10:44:22Z")

</div>

Has supporting macros in noir similar to rust ones been discussed? It would be very helpful to avoid aztec3 contract devs the hassle of needing to to do this in every secret function:

```rust
  fn transfer(
        // ********************************* /
        // Should eventually be hidden:
        inputs: pub Inputs,
        // ********************************* /
        amount: pub Field, 
        sender: pub Point, 
        recipient: pub Point,
    ) -> pub [Field; dep::aztec3::abi::PUBLIC_INPUTS_LENGTH] {
        context.args = context.args.push(amount);
        context.args = context.args.push_array(sender.serialize());
        context.args = context.args.push_array(recipient.serialize());

        context.return_values = context.return_values.push(result);

        context.finish(inputs)
    }

```

Being able to code a macro in the noir-aztec3 that would do the following transformation at the ast level would be amazing:

```rust
    #[secret_fn()]
    fn transfer(
        amount: pub Field, 
        sender: pub Point, 
        recipient: pub Point,
    ) -> pub Point {
        
        result
    }

```

to

```rust
   fn transfer(
        inputs: pub Inputs,
        amount: pub Field, 
        sender: pub Point, 
        recipient: pub Point,
    ) -> pub [Field; dep::aztec3::abi::PUBLIC_INPUTS_LENGTH] {
        context.args = context.args.push(amount);
        context.args = context.args.push_array(sender.serialize());
        context.args = context.args.push_array(recipient.serialize());

        let result = transfer_internal(amount, sender, recipient);

        context.return_values = context.return_values.push_array(result.serialize());

        context.finish(inputs)
    }

    fn transfer_internal(
        amount: Field, 
        sender: Point, 
        recipient: Point,
    ) -> Point {
        
        result
    }

```

Maybe since we have an aztec3-specific compiler that uses `noir_wasm`, we could have a transformation function as callbacks called by `noir_wasm`? For example, if it finds a macro in the code and is executing in the wasm environment it could call back JS to have it modify the tree.

It could be done as a preprocessing step of the noir code but in that case we’d have to parse noir in typescript, which isn’t ideal.
