Official VS Code extension for developing GenLayer intelligent contracts with Python, featuring real-time linting, code intelligence, and deployment tools.
- Automatic validation of GenVM contract files on save and edit
- Inline diagnostics with error squiggles and hover information
- Comprehensive rule checking for GenVM-specific syntax and patterns
- Smart snippets for common GenVM patterns
- Syntax highlighting for GenVM-specific types and decorators
- Auto-completion for GenVM types and decorators
- Rule filtering - enable/disable specific linting rules
- Severity levels - customize error/warning/info levels
- Workspace settings - per-project configuration
-
Python 3.8+ with the GenVM linter package installed:
pip install genvm-linter
-
VS Code 1.74.0+
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "GenVM Linter"
- Click Install
- Download the
.vsixfile - In VS Code, press Ctrl+Shift+P
- Type "Extensions: Install from VSIX"
- Select the downloaded
.vsixfile
The extension automatically detects GenVM contract files by looking for:
- Files with the GenVM magic comment:
# { "Depends": "py-genlayer:test" } - Python files with "contract", "genvm", or "genlayer" in the filename
Access these commands via the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on Mac):
- GenLayer: Lint Current File - Lint the active Python file for GenLayer compliance
- GenLayer: Lint Workspace - Lint all GenLayer contracts in the workspace
- GenLayer: Show GenLayer Output - Show the GenLayer output channel with diagnostic logs
- GenLayer: Debug - Display debug information about the extension and linter
- GenLayer: Test Lint - Test the linter with a sample contract to verify setup
- GenLayer: Install Dependencies - Install required Python packages (genvm-linter, mypy)
- GenLayer: Create Contract - Create a new intelligent contract from a template
- GenLayer: Deploy Contract - Deploy the current contract to a GenLayer network
Type these prefixes and press Tab:
genvm-contract- Complete contract templategenvm-magic- Magic commentgenvm-import- GenLayer importgenvm-view- Public view methodgenvm-write- Public write methodgenvm-dataclass- Storage dataclassgenvm-treemap- TreeMap fieldgenvm-dynarray- DynArray field
Configure the extension through VS Code settings:
{
"genlayer.linting.enabled": true,
"genlayer.linting.severity": "warning",
"genlayer.linting.showSuggestions": true,
"genlayer.linting.excludeRules": [],
"genlayer.python.interpreterPath": "python3"
}| Setting | Type | Default | Description |
|---|---|---|---|
genlayer.linting.enabled |
boolean | true |
Enable/disable GenLayer linting |
genlayer.linting.severity |
string | "warning" |
Minimum severity to show (error, warning, info) |
genlayer.linting.showSuggestions |
boolean | true |
Show fix suggestions in diagnostics |
genlayer.linting.excludeRules |
array | [] |
Rules to exclude from linting |
genlayer.python.interpreterPath |
string | "python3" |
Path to Python interpreter |
{
"genlayer.linting.enabled": true,
"genlayer.linting.severity": "error",
"genlayer.linting.excludeRules": ["genvm-magic-comment"],
"genlayer.python.interpreterPath": "/usr/local/bin/python3.11"
}The extension validates the following GenVM-specific rules:
- β Magic comment on first line
- β GenLayer import statement
- β
Single contract class extending
gl.Contract
- β
Sized integers in storage (
u256,u64, etc.) - β
GenVM collections (
TreeMap,DynArray) - β
Correct return types (
intnotu256) - β Dataclass storage decorators
- β
Proper
@gl.public.view/@gl.public.writeusage - β No decorators on constructors
- β State modification detection
# { "Depends": "py-genlayer:test" }
from genlayer import *
class TokenContract(gl.Contract):
balance: u256 # β
Correct: sized integer for storage
owner: Address
def __init__(self, initial_balance: int):
self.balance = initial_balance
self.owner = gl.message.sender_address
@gl.public.view # β
Correct: view decorator for read-only
def get_balance(self) -> int: # β
Correct: int return type
return self.balance
@gl.public.write # β
Correct: write decorator for state changes
def transfer(self, to: str, amount: int):
if amount > self.balance:
raise gl.Rollback("Insufficient balance")
self.balance -= amount- Check that Python is installed and accessible
- Verify genvm-linter package is installed:
pip show genvm-linter - Check the GenVM Output channel for error messages
- Ensure Python interpreter path is correct in settings
- Verify file contains GenVM magic comment
- Check that linting is enabled in settings
- Save the file to trigger linting
- Check Output β GenVM Linter for error messages
- Set absolute path in
genlayer.python.interpreterPath - Use the Python interpreter where genvm-linter is installed
- Test manually:
python3 -m genvm_linter.cli --version
- Fork the repository
- Create a feature branch
- Make your changes
- Test the extension
- Submit a pull request
git clone https://github.com/genlayerlabs/vscode-extension.git
cd vscode-extension
npm install
npm run compilePress F5 in VS Code to launch Extension Development Host.
MIT License - see LICENSE for details.
- GenVM Linter - Python CLI package (
pip install genvm-linter) - GenLayer Documentation
- GenLayer Studio
- GenLayer Protocol
