Search code examples
blockchainsubstrate

How can I look at the final code generated by the macros in Parity Substrate?


Substrate uses a lot of macros to make it easier to write runtime modules:

  • construct_runtime!
  • decl_module!
  • decl_storage!
  • decl_event!
  • etc...

However, it is hard to understand what these macros actually do and what the final code looks like. How can I dig deeper into these macros and expansions?


Solution

  • To me, the most comfortable solution is to use cargo expand

    https://github.com/dtolnay/cargo-expand

    cargo install cargo-expand
    

    then just call it from your crate

    cargo expand