PyVax Documentation

Welcome to PyVax, a production-ready CLI tool for deploying Solidity and Python smart contracts to Avalanche C-Chain. It features a unique Python-to-EVM transpiler that allows you to write smart contracts in Python and deploy them directly to the blockchain.

Key Features

  • • Python Smart Contracts with EVM transpilation
  • • Full Solidity support and compilation
  • • Multi-network deployment (Fuji testnet & mainnet)
  • • Secure wallet management with PBKDF2 encryption
  • • Gas estimation and deployment tracking

Installation

Get started with PyVax by cloning the repository and setting up your development environment.

Terminal
# Clone the PyVax CLI repository
git clone https://github.com/ShahiTechnovation/pyvax-cli.git
cd pyvax-cli

# Install PyVax CLI
pip install -e .

# Or with requirements.txt
pip install -r requirements.txt
pip install -e .

# Development installation
pip install -e ".[dev]"

# Initialize new project
python -m avax_cli.cli init my_project
cd my_project
Requirements
  • • Python 3.8 or higher
  • • Git (for version control)
  • • AVAX tokens for deployment (testnet faucet available)

Quick Start

Create your first smart contract in minutes with this step-by-step guide.

1

Initialize a new project

Creates sample contracts, config files, and deployment scripts.

2

Create a wallet

Generate an encrypted wallet for contract deployment.

3

Compile and deploy

Compile Python contracts and deploy to Avalanche networks.

Wallet Management

PyVax includes secure wallet management with PBKDF2 encryption for safe private key storage.

Terminal
# Create new wallet
python -m avax_cli.cli wallet new

# Show wallet info
python -m avax_cli.cli wallet show

# Create wallet with custom password
python -m avax_cli.cli wallet new --password mypassword

# Use custom keystore file
python -m avax_cli.cli wallet new --keystore my_key.json

Important: Fund Your Wallet

Make sure to fund your wallet with AVAX before deploying contracts. Use the Fuji testnet faucet for testing.

Python Smart Contracts

Write smart contracts using familiar Python syntax with PyVax's special contract framework.

contracts/SimpleStorage.py
from avax_cli.py_contracts import PySmartContract

class SimpleStorage(PySmartContract):
    """Simple storage contract in Python."""
    
    def __init__(self):
        super().__init__()
        self.stored_data = self.state_var("stored_data", 0)
    
    @public_function
    def set(self, value: int):
        """Set stored data."""
        self.stored_data = value
        self.event("DataStored", value)
    
    @view_function
    def get(self) -> int:
        """Get stored data."""
        return self.stored_data

Python Contract Features

State Variables: self.state_var(name, value)
Public Functions: @public_function
View Functions: @view_function
Events: self.event(name, *params)
Basic Types: int, str
Familiar Python syntax
contracts/Counter.py
from avax_cli.py_contracts import PySmartContract

class Counter(PySmartContract):
    def __init__(self):
        super().__init__()
        self.count = self.state_var("count", 0)
    
    @public_function
    def increment(self):
        self.count = self.count + 1
        self.event("Incremented", self.count)
    
    @view_function
    def get_count(self) -> int:
        return self.count

Configuration

Configure network settings and deployment parameters in your project's configuration file.

avax_config.json
{
  "network": "fuji",
  "rpc_url": "https://api.avax-test.network/ext/bc/C/rpc",
  "chain_id": 43113,
  "explorer_api_key": ""
}

Supported Networks

NetworkChain IDRPC URL
Fuji (Testnet)43113https://api.avax-test.network/ext/bc/C/rpc
Mainnet43114https://api.avax.network/ext/bc/C/rpc

Compilation & Deployment

Compile your Python contracts to Solidity and deploy them to Avalanche networks with gas estimation.

Terminal
# Compile contracts
python -m avax_cli.cli compile

# Deploy to Fuji testnet (default)
python -m avax_cli.cli deploy SimpleStorage

# Deploy to mainnet
python -m avax_cli.cli deploy SimpleStorage --network mainnet

# Deploy with constructor arguments
python -m avax_cli.cli deploy SimpleStorage --args '[42]'

# Dry run (estimate gas only)
python -m avax_cli.cli deploy SimpleStorage --dry-run

Deployment Scripts

Create custom deployment scripts for complex deployment scenarios and automation.

scripts/deploy.py
#!/usr/bin/env python3
from avax_cli.deployer import deploy_contract
from avax_cli.wallet import WalletManager
import json

# Load configuration
with open("avax_config.json") as f:
    config = json.load(f)

# Deploy contract
wallet = WalletManager()
result = deploy_contract(
    contract_name="SimpleStorage",
    constructor_args=[],
    config=config,
    wallet=wallet
)

print(f"Contract deployed at: {result['address']}")

Security Best Practices

Follow these security guidelines to protect your contracts and private keys.

Private Key Security

  • • Never commit private keys to version control
  • • Use strong passwords for wallet encryption
  • • Backup keystore files securely
  • • Use environment variables for CI/CD

Development Best Practices

  • • Test on Fuji testnet before mainnet deployment
  • • Use dry-run mode to estimate gas costs
  • • Implement proper error handling in contracts
  • • Follow smart contract security patterns

Next Steps

Now that you understand the basics, explore these resources to become a PyVax expert: