Natrix is a vyper linter that checks for common mistakes in vyper contracts. It is designed to be your vyper copilot, helping you to write code that is more secure and efficient.
You can install Natrix using pip:
pip install natrixNatrix supports Vyper compiler versions 0.4.0 and above.
To check a contract:
natrix lint file_to_lint.vyTo check all vyper contract in the current directory:
natrix lint
# or simply
natrixTo generate explicit exports for a contract:
natrix codegen exports path/to/contract.vynatrix --help # Show help message
natrix --version # Show version information
natrix lint --list-rules # List all available rules
natrix lint --disable NTX1 NTX2 # Disable specific rules
natrix lint --rule-config RuleName.param=value # Configure rule parameters
natrix lint -p /path/to/libs /another/path # Add extra paths for imports
natrix codegen exports contract.vy # Generate explicit exportsYou can configure Natrix using a pyproject.toml file in your project root:
[tool.natrix]
# Files or directories to lint (relative to pyproject.toml)
files = ["contracts/", "tests/contracts/"]
# Additional paths to search for imports
path = ["lib", "vendor/contracts"]
# Rules to disable
disabled_rules = ["NTX1", "NTX2"]
# Rule-specific configurations
[tool.natrix.rule_configs.RuleName]
param = "value"Natrix can also be used as a pre-commit hook. This allows to have your contracts checked automatically before you can commit.
To add natrix just add the following lines to your pre-commit-config.yaml config file:
repos:
- repo: https://github.com/albertocentonze/natrix
rev: v0.1.9 # Use the latest version
hooks:
- id: natrixand then install pre-commit in your repository by doing:
pre-commit installNatrix is highly experimental software, I do not take any responsibility for changes to the codebase suggested by this linter that might lead to loss of funds or any other issue.