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.
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.
Install the foundational tools required for shadow contract development in the Aztec realm.
# 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
Initialize the Aztec development environment and Private Execution Environment (PXE).
# 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.
Create and compile a Noir contract that will run within the Aztec PXE environment.
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);
}
}
Compile, deploy, and interact with your shadow contract through the Aztec PXE.
# 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
Understanding the PXE's inner workings is crucial for shadow contract mastery. The PXE orchestrates several mystical components:
Maintains encrypted private state for each account, handling note creation, nullification, and private balance tracking.
Orchestrates the creation of zero-knowledge proofs for private function execution using the Barretenberg proving backend.
Constructs complete Aztec transactions by combining private execution proofs with public function calls and fee payments.
Interfaces with Aztec nodes to submit transactions, query public state, and synchronize with the network.
# .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
# 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
Symptom: Cannot connect to PXE at localhost:8080
Solution: Ensure the Aztec sandbox is running with aztec-cli start-sandbox
Symptom: Proofs take too long to generate or timeout
Solution: Increase memory allocation and ensure BB_THREADS matches your CPU cores
Symptom: Nargo compile fails with dependency issues
Solution: Verify Nargo version compatibility and update dependencies in Nargo.toml
Symptom: Private balances not updating correctly
Solution: Check PXE data directory permissions and restart the PXE service
Ready to master the arcane arts of Noir contract development? Start forging your first shadow contracts in the mystical Aztec realm today.