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.
Get started with PyVax by cloning the repository and setting up your development environment.
# 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
Create your first smart contract in minutes with this step-by-step guide.
Creates sample contracts, config files, and deployment scripts.
Generate an encrypted wallet for contract deployment.
Compile Python contracts and deploy to Avalanche networks.
PyVax includes secure wallet management with PBKDF2 encryption for safe private key storage.
# 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
Make sure to fund your wallet with AVAX before deploying contracts. Use the Fuji testnet faucet for testing.
Write smart contracts using familiar Python syntax with PyVax's special contract framework.
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
self.state_var(name, value)
@public_function
@view_function
self.event(name, *params)
int, str
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
Configure network settings and deployment parameters in your project's configuration file.
{ "network": "fuji", "rpc_url": "https://api.avax-test.network/ext/bc/C/rpc", "chain_id": 43113, "explorer_api_key": "" }
Network | Chain ID | RPC URL |
---|---|---|
Fuji (Testnet) | 43113 | https://api.avax-test.network/ext/bc/C/rpc |
Mainnet | 43114 | https://api.avax.network/ext/bc/C/rpc |
Compile your Python contracts to Solidity and deploy them to Avalanche networks with gas estimation.
# 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
Create custom deployment scripts for complex deployment scenarios and automation.
#!/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']}")
Follow these security guidelines to protect your contracts and private keys.
Now that you understand the basics, explore these resources to become a PyVax expert: