<<<<<<< HEAD
=======
upstream/main
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.
<<<<<<< HEAD
You can find the Easy Private Voting contract in ./src/main.nr. A simple integration test is in ./src/test/e2e/index.test.ts.
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 bun deploy.
=======
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.
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.
Use Node.js version 22.15.0.
Start your codespace from the codespace dropdown.
Get the sandbox, aztec-cli, and other tooling with this command:
bash -i <(curl -s https://install.aztec.network)Install the correct version of the toolkit with:
upstream/main
export VERSION=3.0.0-devnet.5
aztec-up && docker pull aztecprotocol/aztec:$VERSION && docker tag aztecprotocol/aztec:$VERSION aztecprotocol/aztec:latestThis project uses JSON configuration files to manage environment-specific settings:
config/sandbox.json- Configuration for local sandbox developmentconfig/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 configuration files contain network URLs, timeouts, and environment-specific settings. You can modify these files to customize your development environment.
Start the sandbox with:
<<<<<<< HEAD
aztec start --local-network
=======
aztec start --sandbox
>>>>>>> upstream/mainRun scripts and tests with default sandbox configuration:
<<<<<<< HEAD
bun compile && bun codegen # Compile contract and generate TS
bun deploy # Deploy to sandbox
bun test # Run tests on sandbox
=======
yarn compile && yarn codegen # Compile contract and generate TS
yarn deploy # Deploy to sandbox
yarn test # Run tests on sandbox
>>>>>>> upstream/mainAll scripts support a ::devnet suffix to automatically use devnet configuration:
<<<<<<< HEAD
bun deploy::devnet # Deploy to devnet
bun test::devnet # Run tests on devnet
bun deploy-account::devnet # Deploy account to devnet
bun interaction-existing-contract::devnet # Interact with devnet contracts
=======
yarn deploy::devnet # Deploy to devnet
yarn test::devnet # Run tests on devnet
yarn deploy-account::devnet # Deploy account to devnet
yarn interaction-existing-contract::devnet # Interact with devnet contracts
>>>>>>> upstream/mainThe ::devnet suffix automatically sets ENV=devnet, loading configuration from config/devnet.json.
<<<<<<< HEAD
bun install
=======
yarn install
>>>>>>> upstream/mainaztec-nargo compileor
<<<<<<< HEAD
bun compile
=======
yarn compile
>>>>>>> upstream/mainGenerate the contract artifact JSON and TypeScript interface:
<<<<<<< HEAD
bun codegen
=======
yarn codegen
>>>>>>> upstream/main./store directory. If you restart the sandbox, you will need to delete the ./store directory to avoid errors.
Make sure the sandbox is running before profiling.
aztec start --sandboxThen run an example contract deployment profile with:
<<<<<<< HEAD
bun profile
=======
yarn profile
>>>>>>> upstream/mainYou can specify the bb binary path for faster native proving, e.g.
<<<<<<< HEAD
BB_BINARY_PATH="/home/user/.bb/bb" BB_WORKING_DIRECTORY="/tmp/bb" CRS_PATH="/tmp/bb" bun profile
=======
BB_BINARY_PATH="/home/user/.bb/bb" BB_WORKING_DIRECTORY="/tmp/bb" CRS_PATH="/tmp/bb" yarn profile
>>>>>>> upstream/mainSee the demo-wallet for an example of how to fetch the appropriate bb binary (version and OS) in an application.
Make sure the sandbox is running before running tests.
aztec start --sandboxThen test with:
<<<<<<< HEAD
bun test
=======
yarn test
>>>>>>> upstream/mainTesting will run the TypeScript tests defined in index.test.ts inside ./src/test/e2e, as well as the Aztec Testing eXecution Environment (TXE) tests defined in 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.
You can find a handful of scripts in the ./scripts folder.
./scripts/deploy_account.tsis an example of how to deploy a schnorr account../scripts/deploy_contract.tsis an example of how to deploy a contract../scripts/fees.tsis an example of how to pay for a contract deployment using various fee payment methods../scripts/multiple_wallet.tsis an example of how to deploy a contract from one wallet instance and interact with it from another../scripts/profile_deploy.tsshows how to profile a transaction and print the results. <<<<<<< HEAD./scripts/interaction_existing_contract.tsdemonstrates how to interact with an already deployed voting contract, including casting votes and checking vote counts. =======./scripts/interaction_existing_contract.tsdemonstrates how to interact with an already deployed pod racing contract, including creating games.
upstream/main
./scripts/get_block.tsis an example of how to retrieve and display block information from the Aztec node.
The ./src/utils/ folder contains utility functions:
./src/utils/create_account_from_env.tsprovides functions to create Schnorr accounts from environment variables (SECRET, SIGNING_KEY, and SALT), useful for account management across different environments../src/utils/setup_wallet.tsprovides a function to set up and configure the TestWallet with proper configuration based on the environment../src/utils/deploy_account.tsprovides a function to deploy Schnorr accounts to the network with sponsored fee payment, including key generation and deployment verification../src/utils/sponsored_fpc.tsprovides functions to deploy and manage the SponsoredFPC (Fee Payment Contract) for handling sponsored transaction fees../config/config.tsprovides environment-aware configuration loading, automatically selecting the correct JSON config file based on theENVvariable.
./store directory. If you restart the sandbox, you will need to delete the ./store directory to avoid errors.
<<<<<<< HEAD
bun update
=======
yarn update
>>>>>>> upstream/mainGet the contract code from the monorepo. The script will look at the versions defined in ./Nargo.toml and fetch that version of the code from the monorepo.
<<<<<<< HEAD
bun update
=======
yarn update
>>>>>>> upstream/mainYou may need to update permissions with:
chmod +x .github/scripts/update_contract.shThis repository includes an AGENTS.md file with detailed instructions for setting up your environment, running tests, and creating pull requests. Please read it before contributing changes.
<<<<<<< HEAD
Anvil is a fast local ethereum development node
Anvil is part of the Foundry suit and is installed alongside forge, cast and chisel.
anvil --fork-url <RPC_URL>=======
>>>>>>> upstream/main