Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
POD_RACING_CONTRACT_ADDRESS="0x2320c9938b3e87feb4e475413456d028572f3367e18d61e7d198d342b557f297"
SECRET="0x29aa7f43021f964fe46527ff4df0e9211de94274f54eff12ec81070ee3e16300"
SALT="0x23c46f2dd4450fb881f0b0e70c3974f84dfa9d199493001b3fe8eb136dc612cd"
AZTEC_ENV=sandbox
AZTEC_ENV=local-network
CONTRACT_SALT="0x2d7e8a973f9039f0e2c7771376e131f8ca1c18bd337ee8fa5c6d89db0198645e"
CONTRACT_DEPLOYER="0x2e34557bae428d3c489f67e9aa326b41a09faf03f619969b883e413cbec7bc1c"
CONTRACT_PK_NULLIFIER="0x01498945581e0eb9f8427ad6021184c700ef091d570892c437d12c7d90364bbd170ae506787c5c43d6ca9255d571c10fa9ffa9d141666e290c347c5c9ab7e344"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sandbox Tests
name: Local Network Tests

on:
push:
Expand All @@ -12,12 +12,12 @@ on:
workflow_dispatch:

jobs:
sandbox-tests:
name: Sandbox Tests
local-network-tests:
name: Local Network Tests
runs-on: ubuntu-latest
env:
AZTEC_ENV: sandbox
VERSION: 3.0.0-devnet.5
AZTEC_ENV: local-network
AZTEC_VERSION: 3.0.0-devnet.20251212

steps:
- name: Checkout repository
Expand All @@ -40,17 +40,24 @@ jobs:
- name: Update path
run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH

- name: Set Aztec version and start sandbox
- name: Set Aztec version
run: |
VERSION=${{ env.VERSION }} aztec-up
aztec start --sandbox &
VERSION=${{ env.AZTEC_VERSION }} aztec-up

- name: Wait for sandbox to be ready
# This is a temporary hack to fix a problem with v3 releases.
- name: Manually tag the aztec version as `latest`
run: |
echo "Waiting for sandbox to start..."
docker tag aztecprotocol/aztec:${{ env.AZTEC_VERSION }} aztecprotocol/aztec:latest

- name: Start local Aztec network
run: aztec start --local-network &

- name: Wait for local network to be ready
run: |
echo "Waiting for local network to start..."
for i in {1..30}; do
if curl -s http://localhost:8080/status >/dev/null 2>&1; then
echo "✅ Sandbox is ready!"
echo "✅ Local network is ready!"
break
fi
echo "Waiting... ($i/30)"
Expand All @@ -61,7 +68,7 @@ jobs:
run: yarn

- name: Compile contracts
run: script -e -c "${AZTEC_NARGO:-aztec-nargo} compile && aztec-postprocess-contract"
run: script -e -c "aztec compile"

- name: Generate contract artifacts
run: script -e -c "aztec codegen target --outdir src/artifacts"
Expand Down Expand Up @@ -180,7 +187,7 @@ jobs:
echo "📋 Saved constructor args to .env file"
fi

- name: Run sandbox scripts
- name: Run local network scripts
run: |
script -e -c "yarn fees"
script -e -c "yarn multiple-wallet"
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Repository guidelines for Codex agents

This repository contains TypeScript scripts and Noir contracts for the Aztec sandbox.
This repository contains TypeScript scripts and Noir contracts for the Aztec local network.
Follow these guidelines when contributing:

## Setup
- Use **Node.js v22** with Yarn.
- Install dependencies with `yarn install`.
- Start the Aztec sandbox using `aztec start --sandbox` before running tests or scripts.
- Start the Aztec local network using `aztec start --local-network` before running tests or scripts.

## Development
- Compile contracts with `yarn compile` and generate TypeScript artifacts with `yarn codegen`.
Expand Down
2 changes: 1 addition & 1 deletion Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ authors = [ "" ]
compiler_version = ">=0.18.0"

[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.5", directory = "noir-projects/aztec-nr/aztec" }
aztec = { git = "https://github.com/AztecProtocol/aztec-nr/", tag = "v3.0.0-devnet.20251212", directory = "aztec" }
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

# Aztec Starter

## Sandbox
## Local Network

This repo is meant to be a starting point for learning to write Aztec contracts and tests on the Aztec sandbox (local development environment). It includes an example contract, useful commands in `package.json` and helpful scripts in `./scripts`.
This repo is meant to be a starting point for learning to write Aztec contracts and tests on the Aztec local network (local development environment). It includes an example contract, useful commands in `package.json` and helpful scripts in `./scripts`.

You can find the **Pod Racing Game contract** in `./src/main.nr`. A simple integration test is in `./src/test/e2e/index.test.ts`.

The Pod Racing contract is a two-player competitive game where players allocate points across 5 tracks over multiple rounds. The game demonstrates Aztec's private state capabilities - round choices remain private until players reveal their final scores.

## Devnet

This repo connects to a locally running Aztec Sandbox by default, but can be configured to connect to the devnet by specifying `AZTEC_ENV=devnet` in a `.env` file or by prefixing a command e.g. `AZTEC_ENV=devnet yarn deploy`.
This repo connects to a locally running Aztec local network by default, but can be configured to connect to the devnet by specifying `AZTEC_ENV=devnet` in a `.env` file or by prefixing a command e.g. `AZTEC_ENV=devnet yarn deploy`.

<div align="center">

Expand All @@ -38,7 +38,7 @@ Use **Node.js version 22.15.0**.

[Start your codespace from the codespace dropdown](https://docs.github.com/en/codespaces/getting-started/quickstart).

Get the **sandbox, aztec-cli, and other tooling** with this command:
Get the **local network, aztec-cli, and other tooling** with this command:

```bash
bash -i <(curl -s https://install.aztec.network)
Expand All @@ -47,35 +47,35 @@ bash -i <(curl -s https://install.aztec.network)
Install the correct version of the toolkit with:

```bash
export VERSION=3.0.0-devnet.5
export VERSION=3.0.0-devnet.20251212
aztec-up && docker pull aztecprotocol/aztec:$VERSION && docker tag aztecprotocol/aztec:$VERSION aztecprotocol/aztec:latest
```

### Environment Configuration

This project uses JSON configuration files to manage environment-specific settings:

- `config/sandbox.json` - Configuration for local sandbox development
- `config/local-network.json` - Configuration for local network development
- `config/devnet.json` - Configuration for devnet deployment

The system automatically loads the appropriate configuration file based on the `ENV` environment variable. If `ENV` is not set, it defaults to `sandbox`.
The system automatically loads the appropriate configuration file based on the `ENV` environment variable. If `ENV` is not set, it defaults to `local-network`.

The configuration files contain network URLs, timeouts, and environment-specific settings. You can modify these files to customize your development environment.

### Running on Sandbox (Local Development)
### Running on Local Network (Local Development)

Start the sandbox with:
Start the local network with:

```bash
aztec start --sandbox
aztec start --local-network
```

Run scripts and tests with default sandbox configuration:
Run scripts and tests with default local network configuration:

```bash
yarn compile && yarn codegen # Compile contract and generate TS
yarn deploy # Deploy to sandbox
yarn test # Run tests on sandbox
yarn deploy # Deploy to local network
yarn test # Run tests on local network
```

### Running on Devnet
Expand Down Expand Up @@ -104,7 +104,7 @@ yarn install
## 🏗 **Compile**

```bash
aztec-nargo compile
aztec compile
```

or
Expand All @@ -125,14 +125,14 @@ yarn codegen

---

:warning: Tests and scripts set up and run the Private Execution Environment (PXE) and store PXE data in the `./store` directory. If you restart the sandbox, you will need to delete the `./store` directory to avoid errors.
:warning: Tests and scripts set up and run the Private Execution Environment (PXE) and store PXE data in the `./store` directory. If you restart the local network, you will need to delete the `./store` directory to avoid errors.

## Transaction Profiling

**Make sure the sandbox is running before profiling.**
**Make sure the local network is running before profiling.**

```bash
aztec start --sandbox
aztec start --local-network
```

Then run an example contract deployment profile with:
Expand All @@ -151,10 +151,10 @@ See the [demo-wallet for an example](https://github.com/AztecProtocol/demo-walle

## 🧪 **Test**

**Make sure the sandbox is running before running tests.**
**Make sure the local network is running before running tests.**

```bash
aztec start --sandbox
aztec start --local-network
```

Then test with:
Expand All @@ -165,7 +165,7 @@ yarn test

Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test/e2e`, as well as the [Aztec Testing eXecution Environment (TXE)](https://docs.aztec.network/developers/guides/smart_contracts/testing) tests defined in [`first.nr`](./src/test/first.nr) (imported in the contract file with `mod test;`).

Note: The Typescript tests spawn an instance of the sandbox to test against, and close it once the TS tests are complete.
Note: The Typescript tests spawn an instance of the local network to test against, and close it once the TS tests are complete.

---

Expand Down Expand Up @@ -193,7 +193,7 @@ The `./src/utils/` folder contains utility functions:

## ❗ **Error Resolution**

:warning: Tests and scripts set up and run the Private Execution Environment (PXE) and store PXE data in the `./store` directory. If you restart the sandbox, you will need to delete the `./store` directory to avoid errors.
:warning: Tests and scripts set up and run the Private Execution Environment (PXE) and store PXE data in the `./store` directory. If you restart the local network, you will need to delete the `./store` directory to avoid errors.

### 🔄 **Update Node.js and Noir Dependencies**

Expand Down
6 changes: 3 additions & 3 deletions config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface EnvironmentConfig {
environment: 'local' | 'testnet' | 'devnet' | 'mainnet';
network: NetworkConfig;
settings: {
skipSandbox: boolean;
skipLocalNetwork: boolean;
version: string;
};
timeouts?: TimeoutConfig;
Expand All @@ -34,7 +34,7 @@ export class ConfigManager {
private configPath: string;

private constructor() {
const env = process.env.AZTEC_ENV || 'sandbox';
const env = process.env.AZTEC_ENV || 'local-network';
this.configPath = path.resolve(process.cwd(), `config/${env}.json`);
this.loadConfig();
console.log(`Loaded configuration: ${this.config.name} environment`);
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ConfigManager {
return this.config.environment === 'devnet';
}

public isSandbox(): boolean {
public isLocalNetwork(): boolean {
return this.config.environment === 'local';
}

Expand Down
6 changes: 3 additions & 3 deletions config/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "devnet",
"environment": "devnet",
"network": {
"nodeUrl": "https://devnet.aztec-labs.com/",
"nodeUrl": "https://next.devnet.aztec-labs.com",
"l1RpcUrl": "https://ethereum-sepolia-rpc.publicnode.com",
"l1ChainId": 11155111
},
"settings": {
"skipSandbox": true,
"version": "3.0.0-devnet.5"
"skipLocalNetwork": true,
"version": "3.0.0-devnet.20251212"
},
"timeouts": {
"deployTimeout": 1200000,
Expand Down
8 changes: 4 additions & 4 deletions config/sandbox.json → config/local-network.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "sandbox",
"name": "local-network",
"environment": "local",
"network": {
"nodeUrl": "http://localhost:8080",
"l1RpcUrl": "http://localhost:8545",
"l1ChainId": 31337
},
"settings": {
"skipSandbox": false,
"version": "3.0.0-devnet.5"
"skipLocalNetwork": false,
"version": "3.0.0-devnet.20251212"
},
"timeouts": {
"deployTimeout": 120000,
"txTimeout": 60000,
"waitTimeout": 30000
}
}
}
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "rm -rf ./src/artifacts ./target",
"clear-store": "rm -rf ./store",
"codegen": "aztec codegen target --outdir src/artifacts",
"compile": "${AZTEC_NARGO:-aztec-nargo} compile && aztec-postprocess-contract",
"compile": "aztec compile",
"deploy": "NODE_NO_WARNINGS=1 node --loader ts-node/esm scripts/deploy_contract.ts",
"deploy::devnet": "NODE_NO_WARNINGS=1 AZTEC_ENV=devnet node --loader ts-node/esm scripts/deploy_contract.ts",
"deploy-account": "NODE_NO_WARNINGS=1 node --loader ts-node/esm scripts/deploy_account.ts",
Expand All @@ -30,17 +30,16 @@
"test::devnet": "AZTEC_ENV=devnet yarn test:js",
"test:js": "rm -rf store/pxe && NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json",
"test:nr": "aztec test",
"update": "./.github/scripts/update_contract.sh $(grep -oP 'tag\\s*=\\s*\"\\K[^\"]+' \"Nargo.toml\" | head -1) && yarn && yarn update-readme-version",
"update-readme-version": "node ./.github/scripts/update-readme-version.js"
},
"dependencies": {
"@aztec/accounts": "3.0.0-devnet.5",
"@aztec/aztec.js": "3.0.0-devnet.5",
"@aztec/noir-contracts.js": "3.0.0-devnet.5",
"@aztec/protocol-contracts": "3.0.0-devnet.5",
"@aztec/pxe": "3.0.0-devnet.5",
"@aztec/stdlib": "3.0.0-devnet.5",
"@aztec/test-wallet": "3.0.0-devnet.5",
"@aztec/accounts": "3.0.0-devnet.20251212",
"@aztec/aztec.js": "3.0.0-devnet.20251212",
"@aztec/noir-contracts.js": "3.0.0-devnet.20251212",
"@aztec/protocol-contracts": "3.0.0-devnet.20251212",
"@aztec/pxe": "3.0.0-devnet.20251212",
"@aztec/stdlib": "3.0.0-devnet.20251212",
"@aztec/test-wallet": "3.0.0-devnet.20251212",
"dotenv": "^17.2.2"
},
"devDependencies": {
Expand Down
11 changes: 4 additions & 7 deletions scripts/deploy_contract.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { PodRacingContract } from "../src/artifacts/PodRacing.js"
import { Logger, createLogger } from "@aztec/aztec.js/log";
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
import { Fr } from "@aztec/aztec.js/fields";
import { TokenContract } from "@aztec/noir-contracts.js/Token"
import { setupWallet } from "../src/utils/setup_wallet.js";
import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js";
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
Expand All @@ -28,7 +26,7 @@ async function main() {
logger.info(`💰 Sponsored FPC instance obtained at: ${sponsoredFPC.address}`);

logger.info('📝 Registering sponsored FPC contract with wallet...');
await wallet.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
await wallet.registerContract(sponsoredFPC, SponsoredFPCContract.artifact);
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
logger.info('✅ Sponsored fee payment method configured');

Expand All @@ -42,13 +40,13 @@ async function main() {
logger.info('🏎️ Starting pod racing contract deployment...');
logger.info(`📋 Admin address for pod racing contract: ${address}`);

const deployTx = PodRacingContract.deploy(wallet, address).send({
const deployMethod = PodRacingContract.deploy(wallet, address).send({
from: address,
fee: { paymentMethod: sponsoredPaymentMethod }
});

logger.info('⏳ Waiting for deployment transaction to be mined...');
const podRacingContract = await deployTx.deployed({ timeout: timeouts.deployTimeout });
const podRacingContract = await deployMethod.deployed({ timeout: timeouts.deployTimeout });

logger.info(`🎉 Pod Racing Contract deployed successfully!`);
logger.info(`📍 Contract address: ${podRacingContract.address}`);
Expand All @@ -59,7 +57,7 @@ async function main() {
logger.info('✅ Contract deployed and ready for game creation');

// Get contract instance for instantiation data
const instance = podRacingContract.instance;
const instance = await deployMethod.getInstance();
if (instance) {
logger.info('📦 Contract instantiation data:');
logger.info(`Salt: ${instance.salt}`);
Expand All @@ -72,7 +70,6 @@ async function main() {
}
logger.info(`Constructor args: ${JSON.stringify([address.toString()])}`);
}

logger.info('🏁 Deployment process completed successfully!');
logger.info(`📋 Summary:`);
logger.info(` - Contract Address: ${podRacingContract.address}`);
Expand Down
Loading