Xian Contract Linter - VS Code Extension
Real-time linter for Xian smart contracts that provides framework-specific validation directly in your editor.
🚀 Features
Linting & Analysis
- Real-time analysis while you write code
- Automatic detection of Xian contracts (files with
con_
prefix or containing specific elements)
- Specific validation of Xian rules and restrictions
- No external dependencies - everything works locally
- Complete integration with VS Code
Wallet Integration & Deployment 🆕
- 🔐 Secure wallet management - Import and store your private keys securely (encrypted in SecretStorage)
- 💰 Wallet info with native balance - View XIAN balance directly in the extension
- 🚀 One-click deployment - Deploy contracts directly from VS Code
- ⚙️ Network configuration - Configure RPC and explorer URLs
- 📊 Transaction monitoring - Track deployment status and view in explorer
- 🔒 Password protection - Encrypted private key storage
🔍 What it detects
Syntax Errors
- Prohibited functions (
eval
, exec
, open
, etc.)
- Disallowed imports (system modules)
- Incorrect use of
try/except
- Invalid names with
_
prefix
Security
- Correct usage of
ctx.caller
vs ctx.signer
- Balance validation before operations
- Access control with
assert
- Imported contract verification
- Expensive operations in loops
- Multiple storage reads
- Efficient use of crypto functions
Best Practices
- Correct contract structure
@export
and @construct
functions
- Use of
random.seed()
- Descriptive messages in
assert
📦 Installation
- Download the
.vsix
extension file
- In VS Code Insiders, go to Extensions (Ctrl+Shift+X)
- Click the three dots (...) and select "Install from VSIX..."
- Select the downloaded file
⚙️ Configuration
The extension can be configured from VS Code Settings:
xianLinter.enabled
: Enable/disable the linter
xianLinter.autoDetect
: Automatically detect Xian contracts
xianLinter.showSuggestions
: Show best practice suggestions
xianLinter.strictMode
: Strict mode (warnings as errors)
🎯 Usage
The extension works automatically:
- Open any
.py
file
- If it's a Xian contract, you'll see real-time indicators
- Errors appear underlined in red
- Warnings in yellow
- Suggestions in blue
Available commands
Linting Commands
Xian Linter: Analyze current file
- Analyzes the active file
Xian Linter: Toggle Linter
- Toggle the linter
Wallet & Deployment Commands 🆕
Xian Wallet: Import Wallet
- Import your private key to enable deployment
Xian Wallet: Configure RPC
- Set up network configuration
Xian Wallet: Show Wallet Info
- View wallet, native balance, and network information
Xian Wallet: Remove Wallet
- Remove wallet from extension
Xian Linter: Deploy Contract
- Deploy the current contract (button in tab bar)
🚀 Getting Started with Contract Deployment
1. Import Your Wallet
- Open Command Palette (
Ctrl+Shift+P
)
- Run
Xian Wallet: Import Wallet
- Enter your 64-character private key
- Set a secure password for encryption
- Optionally configure RPC settings
2. Deploy a Contract
- Open a Xian contract file (
.py
with con_
prefix or containing @export
)
- Click the deploy button (🚀) in the tab bar, or use
Xian Linter: Deploy Contract
- Enter contract name (must start with
con_
)
- Provide constructor arguments (JSON format, if needed)
- Set stamp limit (gas limit)
- Enter your wallet password
- Monitor deployment progress and get transaction hash
3. Network Configuration
- Default: Xian mainnet (
https://node.xian.org
)
- Use
Xian Wallet: Configure RPC
to change networks
- Supports custom RPC and explorer URLs
� Security recommendations
Practical recommendations:
- Use strong, unique passwords preferably > 12 characters (ideally ≥ 16) to protect your private key encryption.
- Treat this wallet as “hot wallet”: keep limited funds and use trusted environments (VS Code Workspace Trust, up-to-date OS, trusted extensions).
- Keep the RPC on HTTPS and avoid unofficial URLs.
- Avoid sharing screenshots/logs that may include sensitive data.
�🔧 Development
To compile the extension:
npm install
npm run compile
To create the VSIX package:
npm install -g vsce
vsce package
📝 Usage example
# ❌ This will generate warnings
def _private_function(): # _ prefix not allowed
print("Hello") # print() not available
# ✅ This is correct
@export
def transfer(to: str, amount: float):
assert amount > 0, "Amount must be positive"
# ... transfer logic
🤝 Contributing
- Fork the project
- Create a branch for your feature
- Commit your changes
- Push to the branch
- Open a Pull Request
📄 License
MIT License - see the LICENSE file for more details.