Shadow Forge Mastery

Master the arcane arts of shadow contract development within the mystical Aztec realm. Learn to wield the ancient PXE (Private eXecution Environment) to manifest your Noir enchantments into reality.

Aztec PXE Mastery
Noir Contract Forging
Swift Deployment Rituals

Aztec PXE: The Private Execution Sanctum

The Private eXecution Environment (PXE) is the sacred sanctum where your Noir shadow contracts come to life within the Aztec realm. This mystical environment handles the complex rituals of proof generation, transaction assembly, and private state management.

Sanctum Prerequisites

Mystical System Requirements

  • Node.js 18+ - The JavaScript runtime engine
  • Docker - Containerization for the Aztec sandbox realm
  • Git - Version control for your shadow contracts
  • 8GB+ RAM - Memory for proof generation rituals
  • 50GB+ Storage - Space for blockchain data and artifacts

Forge Master Tools

Essential Development Arsenal

  • Nargo - The Noir compiler and package manager
  • Aztec CLI - Command-line interface for Aztec operations
  • Aztec.js SDK - JavaScript library for PXE interaction
  • Barretenberg - Proving backend for ZK circuits
  • VS Code + Noir Extension - IDE with syntax highlighting

The Sacred Ritual of Environment Preparation

1

Prepare the Sanctum

Install the foundational tools required for shadow contract development in the Aztec realm.

Terminal Incantations
# Install Node.js (v18 or higher)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install Docker for the Aztec sandbox
sudo apt-get update
sudo apt-get install docker.io docker-compose

# Install Nargo (Noir compiler)
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup

# Verify installations
node --version && docker --version && nargo --version
2

Summon the Aztec Sandbox

Initialize the Aztec development environment and Private Execution Environment (PXE).

Aztec Summoning Ritual
# Install Aztec CLI globally
npm install -g @aztec/cli

# Create new Aztec project
aztec-cli create-project my-shadow-contracts
cd my-shadow-contracts

# Start the Aztec sandbox (includes PXE)
aztec-cli start-sandbox

# In a new terminal, check sandbox status
aztec-cli get-node-info

Note: The sandbox includes a local Aztec node, PXE, and test accounts with pre-funded balances for development.

3

Forge Your First Shadow Contract

Create and compile a Noir contract that will run within the Aztec PXE environment.

contracts/src/main.nr
contract ShadowVault {
    use dep::aztec::prelude::*;
    
    #[aztec(storage)]
    struct Storage {
        balances: PrivateMutable<U128>,
        total_supply: PublicMutable<U128>,
    }
    
    #[aztec(private)]
    fn deposit_treasure(amount: U128) {
        let sender = context.msg_sender();
        
        // Update private balance
        let current_balance = storage.balances.read();
        storage.balances.write(current_balance + amount);
        
        // Update public total supply
        context.call_public_function(
            context.this_address(),
            FunctionSelector::from_signature("_increase_total_supply(U128)"),
            [amount.to_field()]
        );
    }
    
    #[aztec(public)]
    internal fn _increase_total_supply(amount: U128) {
        let current_supply = storage.total_supply.read();
        storage.total_supply.write(current_supply + amount);
    }
}
4

Manifest Contract in the Realm

Compile, deploy, and interact with your shadow contract through the Aztec PXE.

Deployment Ritual
# Compile the Noir contract
nargo compile

# Deploy to the Aztec sandbox
aztec-cli deploy ./target/shadow_vault-ShadowVault.json \
  --private-key 0x123...abc \
  --rpc-url http://localhost:8080

# Interact with deployed contract
aztec-cli call-private \
  --contract-address 0x456...def \
  --function deposit_treasure \
  --args 1000 \
  --private-key 0x123...abc

The Mystical Architecture of PXE

Understanding the PXE's inner workings is crucial for shadow contract mastery. The PXE orchestrates several mystical components:

Private State Management

Maintains encrypted private state for each account, handling note creation, nullification, and private balance tracking.

Proof Generation

Orchestrates the creation of zero-knowledge proofs for private function execution using the Barretenberg proving backend.

Transaction Assembly

Constructs complete Aztec transactions by combining private execution proofs with public function calls and fee payments.

Node Communication

Interfaces with Aztec nodes to submit transactions, query public state, and synchronize with the network.

Advanced Sanctum Configuration

PXE Configuration

Environment Variables

# .env file configuration
PXE_URL=http://localhost:8080
AZTEC_NODE_URL=http://localhost:8081
ETHEREUM_RPC_URL=http://localhost:8545

# Custom PXE settings
PXE_BLOCK_POLLING_INTERVAL_MS=1000
PXE_L1_CONTRACTS_ADDRESSES_PATH=./l1-contracts.json
PXE_DATA_DIRECTORY=./pxe-data

Performance Optimization

Proving Backend Settings

# Barretenberg configuration
export BB_BINARY_PATH=/usr/local/bin/bb
export BB_WORKING_DIRECTORY=./bb-cache

# Memory optimization for proof generation
export NODE_OPTIONS="--max-old-space-size=8192"

# Parallel proof generation
export BB_THREADS=4

Troubleshooting Common Hexes

PXE Connection Failures

Symptom: Cannot connect to PXE at localhost:8080

Solution: Ensure the Aztec sandbox is running with aztec-cli start-sandbox

Proof Generation Timeouts

Symptom: Proofs take too long to generate or timeout

Solution: Increase memory allocation and ensure BB_THREADS matches your CPU cores

Contract Compilation Errors

Symptom: Nargo compile fails with dependency issues

Solution: Verify Nargo version compatibility and update dependencies in Nargo.toml

Private State Sync Issues

Symptom: Private balances not updating correctly

Solution: Check PXE data directory permissions and restart the PXE service

Begin Your Shadow Forge Journey

Ready to master the arcane arts of Noir contract development? Start forging your first shadow contracts in the mystical Aztec realm today.