Quick Start
This guide will help you get up and running with Natrix quickly.
Prerequisites
- Python (version 3.10 or higher)
Installation
You can install Natrix using various package managers:
Usage
To analyze a Vyper contract:
You can also analyze multiple files at once:
Code Generation
Natrix includes code generation utilities to help with various tasks:
Generate Explicit Exports
Generate explicit exports for a contract to fix the implicit export warning:
Generate Call Graph
Visualize the function call relationships in your contract using Mermaid diagrams:
# Generate call graph for entire contract
natrix codegen call_graph path/to/your/contract.vy
# Generate call graph for a specific function and its dependencies
natrix codegen call_graph path/to/your/contract.vy:function_name
The call graph generator will output a Mermaid diagram that shows:
- All functions in your contract
- Which functions call which other functions
- External calls to other contracts (e.g., AMM.withdraw)
Example output:
%%{init: {
"flowchart": {
"nodeSpacing": 100,
"rankSpacing": 400
}
}}%%
flowchart TD
N0["repay"]
N1["_debt"]
N2["AMM.withdraw"]
N0 --> N1
N0 --> N2
You can copy this output to any Mermaid-compatible viewer to visualize your contract's structure.
Integration with pre-commit
You can use Natrix with pre-commit to automatically lint your Vyper files before each commit.
- Add a
.pre-commit-config.yamlfile to your project with the following content:
repos:
- repo: https://github.com/AlbertoCentonze/natrix
rev: v0.1.9 # Use the latest version
hooks:
- id: natrix
- Install the hooks:
Next Steps
- For advanced configuration options, see the Configuration guide
- Explore the available Rules to understand what Natrix can check for
- Learn more about Development if you want to contribute