From d6e0d12c5428e5d134d52839f4cec23ce08c5a54 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:19:58 +0800 Subject: [PATCH 01/28] Create aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 94 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 aztec-testnet-setup.sh diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh new file mode 100644 index 0000000..f52fe46 --- /dev/null +++ b/aztec-testnet-setup.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# Aztec Testnet Setup Script +# This script automates the setup and interaction with the Aztec testnet in a Docker environment. + +# Exit on any error +set -e + +# Define environment variables +export NODE_URL=http://34.107.66.170 +export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 +export AZTEC_VERSION=0.85.0-alpha-testnet.5 + +echo "Starting Aztec Testnet Setup..." + +# Step 1: Install Aztec CLI +echo "Installing Aztec CLI..." +bash -i <(curl -s https://install.aztec.network) + +# Step 2: Install specific testnet version +echo "Installing Aztec testnet version $AZTEC_VERSION..." +aztec-up alpha-testnet + +# Step 3: Create a new account +echo "Creating a new account..." +aztec-wallet create-account \ + --register-only \ + --node-url $NODE_URL \ + --alias my-wallet + +# Step 4: Register account with fee sponsor contract +echo "Registering account with fee sponsor contract..." +aztec-wallet register-contract \ + --node-url $NODE_URL \ + --from my-wallet \ + --alias sponsoredfpc \ + $SPONSORED_FPC_ADDRESS SponsoredFPC \ + --salt 0 + +# Step 5: Deploy the account +echo "Deploying account..." +aztec-wallet deploy-account \ + --node-url $NODE_URL \ + --from my-wallet \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --register-class + +# Step 6: Deploy a token contract +echo "Deploying token contract..." +aztec-wallet deploy \ + --node-url $NODE_URL \ + --from accounts:my-wallet \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --alias token \ + TokenContract \ + --args accounts:my-wallet Token TOK 18 + +# Step 7: Mint 10 private tokens +echo "Minting 10 private tokens..." +aztec-wallet send mint_to_private \ + --node-url $NODE_URL \ + --from accounts:my-wallet \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --contract-address last \ + --args accounts:my-wallet accounts:my-wallet 10 + +# Step 8: Transfer 2 private tokens to public +echo "Transferring 2 private tokens to public..." +aztec-wallet send transfer_to_public \ + --node-url $NODE_URL \ + --from accounts:my-wallet \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --contract-address last \ + --args accounts:my-wallet accounts:my-wallet 2 0 + +# Step 9: Check private balance +echo "Checking private balance..." +aztec-wallet simulate balance_of_private \ + --node-url $NODE_URL \ + --from my-wallet \ + --contract-address last \ + --args accounts:my-wallet + +# Step 10: Check public balance +echo "Checking public balance..." +aztec-wallet simulate balance_of_public \ + --node-url $NODE_URL \ + --from my-wallet \ + --contract-address last \ + --args accounts:my-wallet + +echo "Aztec Testnet Setup Complete!" +echo "Private balance should be 8n, and public balance should be 2n." +echo "You can now explore further with the Aztec testnet!" From 433d03d777784703af40790c1424d90a3ee74a27 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:20:35 +0800 Subject: [PATCH 02/28] Create Dockerfile --- Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e85ed1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Use a lightweight Ubuntu base image +FROM ubuntu:22.04 + +# Install dependencies +RUN apt-get update && apt-get install -y \ + curl \ + bash \ + && rm -rf /var/lib/apt/lists/* + +# Install Docker (needed for Aztec CLI) +RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh + +# Copy the setup script +COPY aztec-testnet-setup.sh /aztec-testnet-setup.sh + +# Make the script executable +RUN chmod +x /aztec-testnet-setup.sh + +# Set working directory +WORKDIR / + +# Run the script +CMD ["/bin/bash", "/aztec-testnet-setup.sh"] From 0b85983f7531344043b9022655c99f41ab13191e Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:26:21 +0800 Subject: [PATCH 03/28] Update README.md --- README.md | 117 ++++++++++++------------------------------------------ 1 file changed, 25 insertions(+), 92 deletions(-) diff --git a/README.md b/README.md index a722a76..47bd23f 100644 --- a/README.md +++ b/README.md @@ -32,107 +32,40 @@ If you are interested in trying out this repo with the testnet, try the [testnet --- -## ๐Ÿš€ **Getting Started** +# Aztec Testnet Setup Guide -Use **Node.js version 18.19.0**. +This repository provides a script to automate the setup and interaction with the Aztec testnet using a single command in a Docker container. -[Start your codespace from the codespace dropdown](https://docs.github.com/en/codespaces/getting-started/quickstart). +## Prerequisites +- Docker installed on your machine. -Get the **sandbox, aztec-cli, and other tooling** with this command: +## Usage +1. Clone the repository: + ```bash + git clone https://github.com/Gmhax/aztec-starter.git + cd aztec-starter + - Build the Docker image + ```bash + docker build -t aztec-testnet . + ``` + - Run the Docker container: + ```bash + docker run --rm aztec-testnet + ``` -```bash -bash -i <(curl -s https://install.aztec.network) -``` + - Follow the output to see the setup process, including account creation, contract deployment, token minting, and balance checking. -Install the correct version of the toolkit with: +## Expected Output +- Private balance: 8n +- Public balance: 2n -```bash -aztec-up 0.86.0 -``` +## Notes +- The script uses Aztec testnet version 0.85.0-alpha-testnet.5. +- If you encounter a Timeout awaiting isMined message, the transaction is still processing and you can proceed. +- For further exploration, refer to the Aztec documentation. -Start the sandbox with: -```bash -aztec start --sandbox -``` ---- - -## ๐Ÿ“ฆ **Install Packages** - -We need to ignore node version warnings (a temporary fix): - -```bash -YARN_IGNORE_ENGINES=true yarn install -``` - ---- - -## ๐Ÿ— **Compile** - -```bash -aztec-nargo compile -``` - -or - -```bash -yarn compile -``` - ---- - -## ๐Ÿ”ง **Codegen** - -Generate the **contract artifact JSON** and TypeScript interface: - -```bash -yarn codegen -``` - ---- - -## ๐Ÿงช **Test** - -**Make sure the sandbox is running before running tests.** - -```bash -aztec start --sandbox -``` - -Then test with: - -```bash -yarn test -``` - -Testing will run the **TypeScript tests** defined in `index.test.ts` inside `./src/test`, 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. - ---- - -## โ— **Error Resolution** - -### ๐Ÿ”„ **Update Node.js and Noir Dependencies** - -```bash -yarn update -``` - -### ๐Ÿ”„ **Update Contract** - -Get 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. - -```bash -yarn update -``` - -You may need to update permissions with: - -```bash -chmod +x update_contract.sh -``` ### ๐Ÿ’ฌ Join the Community: From 067345bba4795681d5c5b50adfca611ae7f38195 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:27:12 +0800 Subject: [PATCH 04/28] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 47bd23f..a02f18a 100644 --- a/README.md +++ b/README.md @@ -45,13 +45,13 @@ This repository provides a script to automate the setup and interaction with the git clone https://github.com/Gmhax/aztec-starter.git cd aztec-starter - Build the Docker image - ```bash - docker build -t aztec-testnet . - ``` + ```bash + docker build -t aztec-testnet . + ``` - Run the Docker container: - ```bash - docker run --rm aztec-testnet - ``` + ```bash + docker run --rm aztec-testnet + ``` - Follow the output to see the setup process, including account creation, contract deployment, token minting, and balance checking. From 20cb2b62c170d218ea95a049fb52bad209752346 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:27:56 +0800 Subject: [PATCH 05/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a02f18a..bdad15e 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ This repository provides a script to automate the setup and interaction with the ## Notes - The script uses Aztec testnet version 0.85.0-alpha-testnet.5. - If you encounter a Timeout awaiting isMined message, the transaction is still processing and you can proceed. -- For further exploration, refer to the Aztec documentation. +- For further exploration, refer to the [Aztec documentation.](https://docs.aztec.network/developers/guides/getting_started_on_testnet) From 347fc6ac4f07b01ae40907c40a743dbd4dde8aa0 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:28:25 +0800 Subject: [PATCH 06/28] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bdad15e..9771729 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ This repository provides a script to automate the setup and interaction with the ```bash git clone https://github.com/Gmhax/aztec-starter.git cd aztec-starter + ``` - Build the Docker image ```bash docker build -t aztec-testnet . From f15729b658042cf90523e5210ddd6bc7b1bc0d05 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:42:14 +0800 Subject: [PATCH 07/28] Update README.md --- README.md | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/README.md b/README.md index 9771729..94b9d9c 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,3 @@ - - -# Aztec Starter - -## Sandbox - -This repo is meant to be a starting point for writing Aztec contracts and tests on the Aztec sandbox (local development environment). - -You can find the **Easy Private Voting contract** in `./src/main.nr`. A simple integration test is in `./src/test/index.test.ts`. - -The corresponding tutorial can be found in the [Aztec docs here](https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/private_voting_contract). - -## Testnet - -If you are interested in trying out this repo with the testnet, try the [testnet branch](https://github.com/AztecProtocol/aztec-starter/tree/testnet). The testnet branch is more suitable for simple interactions with the testnet via script, or as a reference to see how to do something against a live, remote network. The `main` branch should be used for getting started with writing contracts and rapid, local testing. - -
- -[![GitHub Repo stars](https://img.shields.io/github/stars/AztecProtocol/aztec-starter?logo=github&color=yellow)](https://github.com/AztecProtocol/aztec-starter/stargazers) -[![GitHub forks](https://img.shields.io/github/forks/AztecProtocol/aztec-starter?logo=github&color=blue)](https://github.com/AztecProtocol/aztec-starter/network/members) -[![Build](https://github.com/AztecProtocol/aztec-starter/actions/workflows/update.yaml/badge.svg)](https://github.com/AztecProtocol/aztec-starter/actions) -[![GitHub last commit](https://img.shields.io/github/last-commit/AztecProtocol/aztec-starter?logo=git)](https://github.com/AztecProtocol/aztec-starter/commits/main) -[![License](https://img.shields.io/github/license/AztecProtocol/aztec-starter)](https://github.com/AztecProtocol/aztec-starter/blob/main/LICENSE) -[![Discord](https://img.shields.io/badge/discord-join%20chat-5B5EA6)](https://discord.gg/aztec) -[![Twitter Follow](https://img.shields.io/twitter/follow/aztecnetwork?style=flat&logo=twitter)](https://x.com/aztecnetwork) - -
- ---- # Aztec Testnet Setup Guide From b52ced0b8e9daade859f60d6301341fed80c102d Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:43:26 +0800 Subject: [PATCH 08/28] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 94b9d9c..e9dba87 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,12 @@ This repository provides a script to automate the setup and interaction with the git clone https://github.com/Gmhax/aztec-starter.git cd aztec-starter ``` + - Build the Docker image ```bash docker build -t aztec-testnet . ``` + - Run the Docker container: ```bash docker run --rm aztec-testnet From fe89e3105728200fb240c1a8389dd370972e191c Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:47:42 +0800 Subject: [PATCH 09/28] Update Dockerfile --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e85ed1b..44b88d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,12 @@ RUN apt-get update && apt-get install -y \ bash \ && rm -rf /var/lib/apt/lists/* -# Install Docker (needed for Aztec CLI) +# Install Docker RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh +# Start Docker daemon in the background +RUN service docker start + # Copy the setup script COPY aztec-testnet-setup.sh /aztec-testnet-setup.sh From 93c5807b5c17e82f94941672aa2ea5402ac6ef3f Mon Sep 17 00:00:00 2001 From: Gmhax Date: Thu, 1 May 2025 23:57:20 +0800 Subject: [PATCH 10/28] Update Dockerfile --- Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 44b88d7..1ddbfa3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,19 @@ # Use a lightweight Ubuntu base image FROM ubuntu:22.04 -# Install dependencies +# Install dependencies (curl, Node.js, and other required tools) RUN apt-get update && apt-get install -y \ curl \ bash \ + nodejs \ + npm \ && rm -rf /var/lib/apt/lists/* -# Install Docker -RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh +# Install Aztec CLI +RUN curl -s https://install.aztec.network | bash -s -- -y -# Start Docker daemon in the background -RUN service docker start +# Ensure Aztec CLI is in PATH +ENV PATH="/root/.aztec/bin:${PATH}" # Copy the setup script COPY aztec-testnet-setup.sh /aztec-testnet-setup.sh From 500956ac3cd79c7690dbf37e42dbc3549b6d9286 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:00:31 +0800 Subject: [PATCH 11/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9dba87..514b8c7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This repository provides a script to automate the setup and interaction with the - Run the Docker container: ```bash - docker run --rm aztec-testnet + docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aztec-testnet ``` - Follow the output to see the setup process, including account creation, contract deployment, token minting, and balance checking. From ca32c2218221d6c24b652766c739135a528784ef Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:11:19 +0800 Subject: [PATCH 12/28] Update Dockerfile --- Dockerfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1ddbfa3..1639a7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,28 @@ # Use a lightweight Ubuntu base image FROM ubuntu:22.04 -# Install dependencies (curl, Node.js, and other required tools) +# Install dependencies (curl, Node.js, Docker, and other required tools) RUN apt-get update && apt-get install -y \ curl \ bash \ nodejs \ npm \ + ca-certificates \ + gnupg \ + lsb-release \ + && rm -rf /var/lib/apt/lists/* + +# Add Dockerโ€™s official GPG key and repository +RUN mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + +# Install Docker +RUN apt-get update && apt-get install -y \ + docker-ce \ + docker-ce-cli \ + containerd.io \ && rm -rf /var/lib/apt/lists/* # Install Aztec CLI From 531b7225c4228f1a4f206f9eb262a2a206eaa62c Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:25:15 +0800 Subject: [PATCH 13/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index f52fe46..de88bc7 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -15,7 +15,8 @@ echo "Starting Aztec Testnet Setup..." # Step 1: Install Aztec CLI echo "Installing Aztec CLI..." -bash -i <(curl -s https://install.aztec.network) +curl -s https://install.aztec.network | bash -s -- -y + # Step 2: Install specific testnet version echo "Installing Aztec testnet version $AZTEC_VERSION..." From 54f6b9c840c5f0bf29dff23d487f2f66ae459afb Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:25:54 +0800 Subject: [PATCH 14/28] Update Dockerfile --- Dockerfile | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1639a7c..fc09c00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -# Use a lightweight Ubuntu base image +# Base image FROM ubuntu:22.04 -# Install dependencies (curl, Node.js, Docker, and other required tools) +# Install system dependencies RUN apt-get update && apt-get install -y \ curl \ bash \ @@ -12,33 +12,26 @@ RUN apt-get update && apt-get install -y \ lsb-release \ && rm -rf /var/lib/apt/lists/* -# Add Dockerโ€™s official GPG key and repository +# Add Docker GPG key and repo RUN mkdir -p /etc/apt/keyrings && \ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null -# Install Docker +# Install Docker CLI (no daemon) RUN apt-get update && apt-get install -y \ - docker-ce \ docker-ce-cli \ containerd.io \ && rm -rf /var/lib/apt/lists/* -# Install Aztec CLI -RUN curl -s https://install.aztec.network | bash -s -- -y - -# Ensure Aztec CLI is in PATH -ENV PATH="/root/.aztec/bin:${PATH}" - -# Copy the setup script +# Copy setup script COPY aztec-testnet-setup.sh /aztec-testnet-setup.sh -# Make the script executable +# Make it executable RUN chmod +x /aztec-testnet-setup.sh # Set working directory WORKDIR / -# Run the script +# Run the script when container starts CMD ["/bin/bash", "/aztec-testnet-setup.sh"] From 9468c61d8ee5ed7022db311f04f1f2a8d0db5ce0 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:30:50 +0800 Subject: [PATCH 15/28] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 514b8c7..e52f060 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,9 @@ This repository provides a script to automate the setup and interaction with the - Run the Docker container: ```bash - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aztec-testnet + docker run -it --rm \ + -v /var/run/docker.sock:/var/run/docker.sock \ + aztec-testnet ``` - Follow the output to see the setup process, including account creation, contract deployment, token minting, and balance checking. From 15f7aa7b5e320c9f59f6a34749c1cf7b1a0b5677 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:33:14 +0800 Subject: [PATCH 16/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index de88bc7..4a9f870 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -17,6 +17,8 @@ echo "Starting Aztec Testnet Setup..." echo "Installing Aztec CLI..." curl -s https://install.aztec.network | bash -s -- -y +# Add Aztec CLI to PATH (IMPORTANT!) +export PATH="/root/.aztec/bin:$PATH" # Step 2: Install specific testnet version echo "Installing Aztec testnet version $AZTEC_VERSION..." From abad792c34d4334e58ae7f0465d6fc95c33ec6ba Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:42:21 +0800 Subject: [PATCH 17/28] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e52f060..4bb9068 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,21 @@ This repository provides a script to automate the setup and interaction with the ## Usage 1. Clone the repository: ```bash - git clone https://github.com/Gmhax/aztec-starter.git - cd aztec-starter + git clone https://github.com/Gmhax/aztec-starter.git + cd aztec-starter ``` - Build the Docker image ```bash docker build -t aztec-testnet . + cd /root ``` - Run the Docker container: ```bash docker run -it --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ + -w /root \ aztec-testnet ``` From 1437558432af135ac53a2b237c9678f4a9885b53 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:42:35 +0800 Subject: [PATCH 18/28] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4bb9068..6f646ce 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ This repository provides a script to automate the setup and interaction with the ## Usage 1. Clone the repository: ```bash - git clone https://github.com/Gmhax/aztec-starter.git - cd aztec-starter + git clone https://github.com/Gmhax/aztec-starter.git + cd aztec-starter ``` - Build the Docker image From 34edcfa3b4cf1a952cd05c14f741a6f6083e2b7e Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:47:57 +0800 Subject: [PATCH 19/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index 4a9f870..4e23f6d 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -40,39 +40,35 @@ aztec-wallet register-contract \ $SPONSORED_FPC_ADDRESS SponsoredFPC \ --salt 0 -# Step 5: Deploy the account +# Step 5: Deploy the account (remove payment-method flag) echo "Deploying account..." aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --register-class -# Step 6: Deploy a token contract +# Step 6: Deploy a token contract (remove payment-method flag) echo "Deploying token contract..." aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --alias token \ TokenContract \ --args accounts:my-wallet Token TOK 18 -# Step 7: Mint 10 private tokens +# Step 7: Mint 10 private tokens (remove payment-method flag) echo "Minting 10 private tokens..." aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 10 -# Step 8: Transfer 2 private tokens to public +# Step 8: Transfer 2 private tokens to public (remove payment-method flag) echo "Transferring 2 private tokens to public..." aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 2 0 From 4c17702b7389c511fd9c1aa016a82538a96ab799 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 00:59:01 +0800 Subject: [PATCH 20/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index 4e23f6d..57f0182 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -17,7 +17,7 @@ echo "Starting Aztec Testnet Setup..." echo "Installing Aztec CLI..." curl -s https://install.aztec.network | bash -s -- -y -# Add Aztec CLI to PATH (IMPORTANT!) +# Add Aztec CLI to PATH export PATH="/root/.aztec/bin:$PATH" # Step 2: Install specific testnet version @@ -40,35 +40,39 @@ aztec-wallet register-contract \ $SPONSORED_FPC_ADDRESS SponsoredFPC \ --salt 0 -# Step 5: Deploy the account (remove payment-method flag) +# Step 5: Deploy the account with sponsored fee payment echo "Deploying account..." aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --register-class -# Step 6: Deploy a token contract (remove payment-method flag) +# Step 6: Deploy a token contract with sponsored fee payment echo "Deploying token contract..." aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --alias token \ TokenContract \ --args accounts:my-wallet Token TOK 18 -# Step 7: Mint 10 private tokens (remove payment-method flag) +# Step 7: Mint 10 private tokens with sponsored fee payment echo "Minting 10 private tokens..." aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 10 -# Step 8: Transfer 2 private tokens to public (remove payment-method flag) +# Step 8: Transfer 2 private tokens to public with sponsored fee payment echo "Transferring 2 private tokens to public..." aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 2 0 From 1b8aaa731a184f386cf4670a8f1c2ce06aa69447 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:04:09 +0800 Subject: [PATCH 21/28] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f646ce..4984d09 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ This repository provides a script to automate the setup and interaction with the ## Prerequisites - Docker installed on your machine. +## you can setup this guide using codespace +- https://github.com/codespaces + ## Usage 1. Clone the repository: ```bash @@ -16,7 +19,6 @@ This repository provides a script to automate the setup and interaction with the - Build the Docker image ```bash docker build -t aztec-testnet . - cd /root ``` - Run the Docker container: From 0056727356ebf902dea1b7ac231d2205e4d61b17 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:15:05 +0800 Subject: [PATCH 22/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index 57f0182..3dc9620 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -45,7 +45,7 @@ echo "Deploying account..." aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --register-class # Step 6: Deploy a token contract with sponsored fee payment @@ -53,7 +53,7 @@ echo "Deploying token contract..." aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --alias token \ TokenContract \ --args accounts:my-wallet Token TOK 18 @@ -63,7 +63,7 @@ echo "Minting 10 private tokens..." aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 10 @@ -72,7 +72,7 @@ echo "Transferring 2 private tokens to public..." aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 2 0 From 06754aa657e02aeaf3e27e60888ff3d9b9443e58 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:21:25 +0800 Subject: [PATCH 23/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index 3dc9620..62ae4d3 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -13,8 +13,13 @@ export AZTEC_VERSION=0.85.0-alpha-testnet.5 echo "Starting Aztec Testnet Setup..." -# Step 1: Install Aztec CLI +# Step 1: Install Aztec CLI (ensure curl is available) echo "Installing Aztec CLI..." +if ! command -v curl &> /dev/null +then + echo "Error: curl is not installed. Install curl first." + exit 1 +fi curl -s https://install.aztec.network | bash -s -- -y # Add Aztec CLI to PATH @@ -45,7 +50,7 @@ echo "Deploying account..." aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --register-class # Step 6: Deploy a token contract with sponsored fee payment @@ -53,7 +58,7 @@ echo "Deploying token contract..." aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --alias token \ TokenContract \ --args accounts:my-wallet Token TOK 18 @@ -63,7 +68,7 @@ echo "Minting 10 private tokens..." aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 10 @@ -72,7 +77,7 @@ echo "Transferring 2 private tokens to public..." aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 2 0 From c90a9b3163e8e62ecf5b8139bf798800b1d1468d Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:33:59 +0800 Subject: [PATCH 24/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 114 +++++++++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 28 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index 62ae4d3..fc62ec4 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -7,96 +7,154 @@ set -e # Define environment variables +# TODO: Verify NODE_URL and SPONSORED_FPC_ADDRESS at https://docs.aztec.network or Aztec Discord export NODE_URL=http://34.107.66.170 export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 export AZTEC_VERSION=0.85.0-alpha-testnet.5 echo "Starting Aztec Testnet Setup..." -# Step 1: Install Aztec CLI (ensure curl is available) -echo "Installing Aztec CLI..." -if ! command -v curl &> /dev/null -then - echo "Error: curl is not installed. Install curl first." +# Step 1: Check prerequisites +echo "Checking prerequisites..." +if ! command -v curl &> /dev/null; then + echo "Error: curl is not installed. Please install curl and try again." + exit 1 +fi +if ! command -v docker &> /dev/null; then + echo "Error: Docker is not installed. Please install Docker and try again." exit 1 fi -curl -s https://install.aztec.network | bash -s -- -y + +# Step 2: Install Aztec CLI +echo "Installing Aztec CLI..." +curl -s https://install.aztec.network | bash -s -- -y || { + echo "Error: Failed to install Aztec CLI. Check network connection or https://docs.aztec.network." + exit 1 +} # Add Aztec CLI to PATH -export PATH="/root/.aztec/bin:$PATH" +export PATH="$HOME/.aztec/bin:$PATH" +if ! command -v aztec &> /dev/null; then + echo "Error: Aztec CLI not found in PATH. Ensure $HOME/.aztec/bin exists." + exit 1 +fi -# Step 2: Install specific testnet version +# Step 3: Install specific testnet version echo "Installing Aztec testnet version $AZTEC_VERSION..." -aztec-up alpha-testnet +aztec-up alpha-testnet || { + echo "Error: Failed to install testnet version $AZTEC_VERSION. Check version compatibility at https://docs.aztec.network." + exit 1 +} -# Step 3: Create a new account +# Step 4: Create a new account echo "Creating a new account..." aztec-wallet create-account \ --register-only \ --node-url $NODE_URL \ - --alias my-wallet + --alias my-wallet || { + echo "Error: Failed to create account. Check NODE_URL ($NODE_URL) and network connectivity." + exit 1 +} -# Step 4: Register account with fee sponsor contract +# Step 5: Register account with fee sponsor contract echo "Registering account with fee sponsor contract..." -aztec-wallet register-contract \ +if aztec-wallet register-contract \ --node-url $NODE_URL \ --from my-wallet \ --alias sponsoredfpc \ $SPONSORED_FPC_ADDRESS SponsoredFPC \ - --salt 0 + --salt 0; then + echo "Fee sponsor contract registered successfully." +else + echo "Error: Failed to register fee sponsor contract. Verify SPONSORED_FPC_ADDRESS ($SPONSORED_FPC_ADDRESS)." + exit 1 +fi -# Step 5: Deploy the account with sponsored fee payment +# Step 6: Deploy the account with sponsored fee payment echo "Deploying account..." -aztec-wallet deploy-account \ +if aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ - --register-class + --register-class; then + echo "Account deployed successfully." +else + echo "Warning: Failed to deploy account with sponsored fees. Retrying without fee sponsor..." + if aztec-wallet deploy-account \ + --node-url $NODE_URL \ + --from my-wallet \ + --register-class; then + echo "Account deployed successfully without fee sponsor." + else + echo "Error: Failed to deploy account. Check NODE_URL, wallet funds, or network status." + echo "Note: If you see 'Timeout awaiting isMined', the transaction may still be pending." + echo "Visit https://docs.aztec.network or Aztec Discord for support." + exit 1 + fi +fi -# Step 6: Deploy a token contract with sponsored fee payment +# Step 7: Deploy a token contract echo "Deploying token contract..." -aztec-wallet deploy \ +if aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --alias token \ TokenContract \ - --args accounts:my-wallet Token TOK 18 + --args accounts:my-wallet Token TOK 18; then + echo "Token contract deployed successfully." +else + echo "Error: Failed to deploy token contract. Check previous steps or fee sponsor." + exit 1 +fi -# Step 7: Mint 10 private tokens with sponsored fee payment +# Step 8: Mint 10 private tokens echo "Minting 10 private tokens..." aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ - --args accounts:my-wallet accounts:my-wallet 10 + --args accounts:my-wallet accounts:my-wallet 10 || { + echo "Error: Failed to mint private tokens. Check contract deployment or fee sponsor." + exit 1 +} -# Step 8: Transfer 2 private tokens to public with sponsored fee payment +# Step 9: Transfer 2 private tokens to public echo "Transferring 2 private tokens to public..." aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ - --args accounts:my-wallet accounts:my-wallet 2 0 + --args accounts:my-wallet accounts:my-wallet 2 0 || { + echo "Error: Failed to transfer tokens to public. Check previous steps." + exit 1 +} -# Step 9: Check private balance +# Step 10: Check private balance echo "Checking private balance..." aztec-wallet simulate balance_of_private \ --node-url $NODE_URL \ --from my-wallet \ --contract-address last \ - --args accounts:my-wallet + --args accounts:my-wallet || { + echo "Error: Failed to check private balance. Expected 8n." + exit 1 +} -# Step 10: Check public balance +# Step 11: Check public balance echo "Checking public balance..." aztec-wallet simulate balance_of_public \ --node-url $NODE_URL \ --from my-wallet \ --contract-address last \ - --args accounts:my-wallet + --args accounts:my-wallet || { + echo "Error: Failed to check public balance. Expected 2n." + exit 1 +} echo "Aztec Testnet Setup Complete!" echo "Private balance should be 8n, and public balance should be 2n." echo "You can now explore further with the Aztec testnet!" +echo "For further assistance, visit https://docs.aztec.network or join the Aztec Discord." From 0e6b70482ca318c530a7f781bc0c44a84c0fd64c Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:43:33 +0800 Subject: [PATCH 25/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 66 +++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index fc62ec4..dd58791 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -14,7 +14,14 @@ export AZTEC_VERSION=0.85.0-alpha-testnet.5 echo "Starting Aztec Testnet Setup..." -# Step 1: Check prerequisites +# Step 1: Prompt user to verify NODE_URL and SPONSORED_FPC_ADDRESS +echo "Using NODE_URL: $NODE_URL" +echo "Using SPONSORED_FPC_ADDRESS: $SPONSORED_FPC_ADDRESS" +echo "Please verify these values at https://docs.aztec.network or Aztec Discord." +echo "Press Enter to continue or Ctrl+C to cancel and update the values." +read -r + +# Step 2: Check prerequisites echo "Checking prerequisites..." if ! command -v curl &> /dev/null; then echo "Error: curl is not installed. Please install curl and try again." @@ -24,8 +31,22 @@ if ! command -v docker &> /dev/null; then echo "Error: Docker is not installed. Please install Docker and try again." exit 1 fi +# Check Docker resources (optional, for proof generation) +echo "Checking Docker resources..." +docker info --format '{{.CPUs}} CPUs, {{.MemTotal}} memory' || { + echo "Warning: Unable to check Docker resources. Ensure at least 2 CPUs and 4GB memory." +} + +# Step 3: Test NODE_URL connectivity +echo "Testing NODE_URL connectivity..." +if curl -s --head "$NODE_URL" | head -n 1 | grep "200" > /dev/null; then + echo "NODE_URL is reachable." +else + echo "Error: NODE_URL ($NODE_URL) is not reachable. Verify the URL at https://docs.aztec.network." + exit 1 +fi -# Step 2: Install Aztec CLI +# Step 4: Install Aztec CLI echo "Installing Aztec CLI..." curl -s https://install.aztec.network | bash -s -- -y || { echo "Error: Failed to install Aztec CLI. Check network connection or https://docs.aztec.network." @@ -39,14 +60,14 @@ if ! command -v aztec &> /dev/null; then exit 1 fi -# Step 3: Install specific testnet version +# Step 5: Install specific testnet version echo "Installing Aztec testnet version $AZTEC_VERSION..." aztec-up alpha-testnet || { echo "Error: Failed to install testnet version $AZTEC_VERSION. Check version compatibility at https://docs.aztec.network." exit 1 } -# Step 4: Create a new account +# Step 6: Create a new account echo "Creating a new account..." aztec-wallet create-account \ --register-only \ @@ -56,7 +77,7 @@ aztec-wallet create-account \ exit 1 } -# Step 5: Register account with fee sponsor contract +# Step 7: Register account with fee sponsor contract echo "Registering account with fee sponsor contract..." if aztec-wallet register-contract \ --node-url $NODE_URL \ @@ -70,35 +91,40 @@ else exit 1 fi -# Step 6: Deploy the account with sponsored fee payment -echo "Deploying account..." +# Step 8: Deploy the account with sponsored fee payment +echo "Deploying account with fee sponsor..." if aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ --register-class; then - echo "Account deployed successfully." + echo "Account deployed successfully with fee sponsor." else - echo "Warning: Failed to deploy account with sponsored fees. Retrying without fee sponsor..." + echo "Warning: Failed to deploy account with fee sponsor (possibly insufficient fee payer balance)." + echo "Retrying without fee sponsor. Ensure your wallet (my-wallet) has testnet funds." + echo "Check for a testnet faucet at https://docs.aztec.network or request funds on Aztec Discord." if aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ --register-class; then echo "Account deployed successfully without fee sponsor." else - echo "Error: Failed to deploy account. Check NODE_URL, wallet funds, or network status." + echo "Error: Failed to deploy account. Possible causes:" + echo "1. Insufficient funds in my-wallet (request testnet funds)." + echo "2. Invalid NODE_URL ($NODE_URL)." + echo "3. Network congestion or server issues (Error 500)." echo "Note: If you see 'Timeout awaiting isMined', the transaction may still be pending." - echo "Visit https://docs.aztec.network or Aztec Discord for support." + echo "Visit https://docs.aztec.network or join Aztec Discord for support." exit 1 fi fi -# Step 7: Deploy a token contract +# Step 9: Deploy a token contract echo "Deploying token contract..." if aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ --alias token \ TokenContract \ --args accounts:my-wallet Token TOK 18; then @@ -108,31 +134,31 @@ else exit 1 fi -# Step 8: Mint 10 private tokens +# Step 10: Mint 10 private tokens echo "Minting 10 private tokens..." aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 10 || { echo "Error: Failed to mint private tokens. Check contract deployment or fee sponsor." exit 1 } -# Step 9: Transfer 2 private tokens to public +# Step 11: Transfer 2 private tokens to public echo "Transferring 2 private tokens to public..." aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment method=fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ --contract-address last \ --args accounts:my-wallet accounts:my-wallet 2 0 || { echo "Error: Failed to transfer tokens to public. Check previous steps." exit 1 } -# Step 10: Check private balance +# Step 12: Check private balance echo "Checking private balance..." aztec-wallet simulate balance_of_private \ --node-url $NODE_URL \ @@ -143,7 +169,7 @@ aztec-wallet simulate balance_of_private \ exit 1 } -# Step 11: Check public balance +# Step 13: Check public balance echo "Checking public balance..." aztec-wallet simulate balance_of_public \ --node-url $NODE_URL \ From c1753ab087140ae35af679eca5d724cab75435cf Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:46:29 +0800 Subject: [PATCH 26/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index dd58791..ac30543 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -8,8 +8,8 @@ set -e # Define environment variables # TODO: Verify NODE_URL and SPONSORED_FPC_ADDRESS at https://docs.aztec.network or Aztec Discord -export NODE_URL=http://34.107.66.170 -export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 +export NODE_URL=http://34.107.66.170 # Replace with the current testnet node URL +export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 # Verify this address export AZTEC_VERSION=0.85.0-alpha-testnet.5 echo "Starting Aztec Testnet Setup..." @@ -31,18 +31,23 @@ if ! command -v docker &> /dev/null; then echo "Error: Docker is not installed. Please install Docker and try again." exit 1 fi -# Check Docker resources (optional, for proof generation) + +# Check Docker resources echo "Checking Docker resources..." -docker info --format '{{.CPUs}} CPUs, {{.MemTotal}} memory' || { +if docker info --format '{{.NCPU}} CPUs, {{.MemTotal}} memory' >/dev/null 2>&1; then + docker info --format 'Available: {{.NCPU}} CPUs, {{.MemTotal}} memory' +else echo "Warning: Unable to check Docker resources. Ensure at least 2 CPUs and 4GB memory." -} + docker info --format 'Docker version: {{.ServerVersion}}' || echo "Error: Docker info unavailable." +fi # Step 3: Test NODE_URL connectivity echo "Testing NODE_URL connectivity..." -if curl -s --head "$NODE_URL" | head -n 1 | grep "200" > /dev/null; then +if curl -s --head "$NODE_URL" | head -n 1 | grep "200" >/dev/null; then echo "NODE_URL is reachable." else - echo "Error: NODE_URL ($NODE_URL) is not reachable. Verify the URL at https://docs.aztec.network." + echo "Error: NODE_URL ($NODE_URL) is not reachable." + echo "Verify the URL at https://docs.aztec.network or ask on Aztec Discord (https://discord.gg/aztec)." exit 1 fi @@ -102,7 +107,8 @@ if aztec-wallet deploy-account \ else echo "Warning: Failed to deploy account with fee sponsor (possibly insufficient fee payer balance)." echo "Retrying without fee sponsor. Ensure your wallet (my-wallet) has testnet funds." - echo "Check for a testnet faucet at https://docs.aztec.network or request funds on Aztec Discord." + echo "Check for a testnet faucet at https://docs.aztec.network or request funds on Aztec Discord (https://discord.gg/aztec)." + echo "To view your wallet address: aztec-wallet list-accounts" if aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ @@ -114,7 +120,7 @@ else echo "2. Invalid NODE_URL ($NODE_URL)." echo "3. Network congestion or server issues (Error 500)." echo "Note: If you see 'Timeout awaiting isMined', the transaction may still be pending." - echo "Visit https://docs.aztec.network or join Aztec Discord for support." + echo "Visit https://docs.aztec.network or join Aztec Discord (https://discord.gg/aztec) for support." exit 1 fi fi @@ -183,4 +189,4 @@ aztec-wallet simulate balance_of_public \ echo "Aztec Testnet Setup Complete!" echo "Private balance should be 8n, and public balance should be 2n." echo "You can now explore further with the Aztec testnet!" -echo "For further assistance, visit https://docs.aztec.network or join the Aztec Discord." +echo "For further assistance, visit https://docs.aztec.network or join the Aztec Discord (https://discord.gg/aztec)." From 18bf014782569bcbdac4730ad21ed27e59a8fa44 Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:53:35 +0800 Subject: [PATCH 27/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 135 ++++++++++++++++++++++++++++++----------- 1 file changed, 100 insertions(+), 35 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index ac30543..caf894b 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -6,20 +6,39 @@ # Exit on any error set -e -# Define environment variables -# TODO: Verify NODE_URL and SPONSORED_FPC_ADDRESS at https://docs.aztec.network or Aztec Discord -export NODE_URL=http://34.107.66.170 # Replace with the current testnet node URL -export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 # Verify this address +# Define environment variables (default values, to be verified by user) +export NODE_URL=http://34.107.66.170 +export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 export AZTEC_VERSION=0.85.0-alpha-testnet.5 +export PAYMENT_METHOD="fpc-sponsored,fpc=contracts:sponsoredfpc" echo "Starting Aztec Testnet Setup..." -# Step 1: Prompt user to verify NODE_URL and SPONSORED_FPC_ADDRESS -echo "Using NODE_URL: $NODE_URL" -echo "Using SPONSORED_FPC_ADDRESS: $SPONSORED_FPC_ADDRESS" -echo "Please verify these values at https://docs.aztec.network or Aztec Discord." -echo "Press Enter to continue or Ctrl+C to cancel and update the values." -read -r +# Step 1: Prompt user to verify or update environment variables +echo "Default values:" +echo "- NODE_URL: $NODE_URL" +echo "- SPONSORED_FPC_ADDRESS: $SPONSORED_FPC_ADDRESS" +echo "- AZTEC_VERSION: $AZTEC_VERSION" +echo "Verify these at https://docs.aztec.network or Aztec Discord (https://discord.gg/aztec)." +echo "Press Enter to use defaults, or enter new values below." + +echo "Enter NODE_URL (or press Enter to keep default):" +read -r new_node_url +if [ -n "$new_node_url" ]; then + export NODE_URL="$new_node_url" +fi + +echo "Enter SPONSORED_FPC_ADDRESS (or press Enter to keep default):" +read -r new_fpc_address +if [ -n "$new_fpc_address" ]; then + export SPONSORED_FPC_ADDRESS="$new_fpc_address" +fi + +echo "Enter AZTEC_VERSION (or press Enter to keep default):" +read -r new_version +if [ -n "$new_version" ]; then + export AZTEC_VERSION="$new_version" +fi # Step 2: Check prerequisites echo "Checking prerequisites..." @@ -32,13 +51,27 @@ if ! command -v docker &> /dev/null; then exit 1 fi +# Check Docker daemon +echo "Checking Docker daemon..." +if ! docker info >/dev/null 2>&1; then + echo "Docker daemon is not running. Attempting to start..." + if command -v systemctl >/dev/null; then + sudo systemctl start docker || { + echo "Error: Failed to start Docker. Please start Docker manually." + exit 1 + } + else + echo "Error: Cannot start Docker automatically. Please start Docker manually." + exit 1 + fi +fi + # Check Docker resources echo "Checking Docker resources..." if docker info --format '{{.NCPU}} CPUs, {{.MemTotal}} memory' >/dev/null 2>&1; then docker info --format 'Available: {{.NCPU}} CPUs, {{.MemTotal}} memory' else echo "Warning: Unable to check Docker resources. Ensure at least 2 CPUs and 4GB memory." - docker info --format 'Docker version: {{.ServerVersion}}' || echo "Error: Docker info unavailable." fi # Step 3: Test NODE_URL connectivity @@ -58,12 +91,21 @@ curl -s https://install.aztec.network | bash -s -- -y || { exit 1 } -# Add Aztec CLI to PATH +# Add Aztec CLI to PATH and offer to make it permanent export PATH="$HOME/.aztec/bin:$PATH" if ! command -v aztec &> /dev/null; then echo "Error: Aztec CLI not found in PATH. Ensure $HOME/.aztec/bin exists." exit 1 fi +echo "Aztec CLI added to PATH for this session." +echo "Do you want to add it permanently to your shell PATH? (y/n)" +read -r add_path +if [ "$add_path" = "y" ]; then + echo 'export PATH="$HOME/.aztec/bin:$PATH"' >> "$HOME/.bashrc" + echo "Added to .bashrc. Run 'source ~/.bashrc' or restart your terminal." +else + echo "Note: You may need to add 'export PATH=\"$HOME/.aztec/bin:$PATH\"' to your shell configuration (e.g., ~/.bashrc) manually." +fi # Step 5: Install specific testnet version echo "Installing Aztec testnet version $AZTEC_VERSION..." @@ -89,7 +131,7 @@ if aztec-wallet register-contract \ --from my-wallet \ --alias sponsoredfpc \ $SPONSORED_FPC_ADDRESS SponsoredFPC \ - --salt 0; then +; then echo "Fee sponsor contract registered successfully." else echo "Error: Failed to register fee sponsor contract. Verify SPONSORED_FPC_ADDRESS ($SPONSORED_FPC_ADDRESS)." @@ -101,11 +143,12 @@ echo "Deploying account with fee sponsor..." if aztec-wallet deploy-account \ --node-url $NODE_URL \ --from my-wallet \ - --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method $PAYMENT_METHOD \ --register-class; then echo "Account deployed successfully with fee sponsor." else - echo "Warning: Failed to deploy account with fee sponsor (possibly insufficient fee payer balance)." + echo "Warning: Failed to deploy account. If you see 'Timeout awaiting isMined', the transaction may still be pending." + echo "Check status with: aztec-wallet list-transactions --from my-wallet" echo "Retrying without fee sponsor. Ensure your wallet (my-wallet) has testnet funds." echo "Check for a testnet faucet at https://docs.aztec.network or request funds on Aztec Discord (https://discord.gg/aztec)." echo "To view your wallet address: aztec-wallet list-accounts" @@ -130,61 +173,83 @@ echo "Deploying token contract..." if aztec-wallet deploy \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method $PAYMENT_METHOD \ --alias token \ TokenContract \ --args accounts:my-wallet Token TOK 18; then echo "Token contract deployed successfully." else - echo "Error: Failed to deploy token contract. Check previous steps or fee sponsor." + echo "Warning: Failed to deploy token contract. If you see 'Timeout awaiting isMined', the transaction may still be pending." + echo "Check status with: aztec-wallet list-transactions --from my-wallet" + echo "Verify previous steps or fee sponsor at https://docs.aztec.network." exit 1 fi # Step 10: Mint 10 private tokens echo "Minting 10 private tokens..." -aztec-wallet send mint_to_private \ +if aztec-wallet send mint_to_private \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method $PAYMENT_METHOD \ --contract-address last \ - --args accounts:my-wallet accounts:my-wallet 10 || { - echo "Error: Failed to mint private tokens. Check contract deployment or fee sponsor." + --args accounts:my-wallet accounts:my-wallet 10; then + echo "Successfully minted 10 private tokens." +else + echo "Warning: Failed to mint private tokens. If you see 'Timeout awaiting isMined', the transaction may still be pending." + echo "Check status with: aztec-wallet list-transactions --from my-wallet" + echo "Verify contract deployment or fee sponsor at https://docs.aztec.network." exit 1 -} +fi # Step 11: Transfer 2 private tokens to public echo "Transferring 2 private tokens to public..." -aztec-wallet send transfer_to_public \ +if aztec-wallet send transfer_to_public \ --node-url $NODE_URL \ --from accounts:my-wallet \ - --payment-method fpc-sponsored,fpc=contracts:sponsoredfpc \ + --payment-method $PAYMENT_METHOD \ --contract-address last \ - --args accounts:my-wallet accounts:my-wallet 2 0 || { - echo "Error: Failed to transfer tokens to public. Check previous steps." + --args accounts:my-wallet accounts:my-wallet 2 0; then + echo "Successfully transferred 2 private tokens to public." +else + echo "Warning: Failed to transfer tokens to public. If you see 'Timeout awaiting isMined', the transaction may still be pending." + echo "Check status with: aztec-wallet list-transactions --from my-wallet" + echo "Verify previous steps at https://docs.aztec.network." exit 1 -} +fi # Step 12: Check private balance echo "Checking private balance..." -aztec-wallet simulate balance_of_private \ +private_balance=$(aztec-wallet simulate balance_of_private \ --node-url $NODE_URL \ --from my-wallet \ --contract-address last \ - --args accounts:my-wallet || { - echo "Error: Failed to check private balance. Expected 8n." + --args accounts:my-wallet 2>/dev/null || { + echo "Error: Failed to check private balance. Verify contract deployment at https://docs.aztec.network." exit 1 -} +}) +if [[ "$private_balance" =~ "8n" ]]; then + echo "Private balance: 8n (as expected)." +else + echo "Warning: Private balance ($private_balance) does not match expected value (8n)." + echo "Verify previous steps at https://docs.aztec.network." +fi # Step 13: Check public balance echo "Checking public balance..." -aztec-wallet simulate balance_of_public \ +public_balance=$(aztec-wallet simulate balance_of_public \ --node-url $NODE_URL \ --from my-wallet \ --contract-address last \ - --args accounts:my-wallet || { - echo "Error: Failed to check public balance. Expected 2n." + --args accounts:my-wallet 2>/dev/null || { + echo "Error: Failed to check public balance. Verify contract deployment at https://docs.aztec.network." exit 1 -} +}) +if [[ "$public_balance" =~ "2n" ]]; then + echo "Public balance: 2n (as expected)." +else + echo "Warning: Public balance ($public_balance) does not match expected value (2n)." + echo "Verify previous steps at https://docs.aztec.network." +fi echo "Aztec Testnet Setup Complete!" echo "Private balance should be 8n, and public balance should be 2n." From 02ed0682a658b416f1806037cbe37ea2038b701f Mon Sep 17 00:00:00 2001 From: Gmhax Date: Fri, 2 May 2025 01:57:40 +0800 Subject: [PATCH 28/28] Update aztec-testnet-setup.sh --- aztec-testnet-setup.sh | 75 +++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/aztec-testnet-setup.sh b/aztec-testnet-setup.sh index caf894b..9a3b4e7 100644 --- a/aztec-testnet-setup.sh +++ b/aztec-testnet-setup.sh @@ -1,7 +1,7 @@ #!/bin/bash # Aztec Testnet Setup Script -# This script automates the setup and interaction with the Aztec testnet in a Docker environment. +# Automates setup and interaction with the Aztec testnet or Sandbox in a Docker environment. # Exit on any error set -e @@ -11,9 +11,34 @@ export NODE_URL=http://34.107.66.170 export SPONSORED_FPC_ADDRESS=0x0b27e30667202907fc700d50e9bc816be42f8141fae8b9f2281873dbdb9fc2e5 export AZTEC_VERSION=0.85.0-alpha-testnet.5 export PAYMENT_METHOD="fpc-sponsored,fpc=contracts:sponsoredfpc" +export SANDBOX_NODE_URL=http://localhost:8545 echo "Starting Aztec Testnet Setup..." +# Function to test NODE_URL connectivity with retries +test_node_url() { + local url=$1 + local retries=3 + local delay=5 + local attempt=1 + + while [ $attempt -le $retries ]; do + echo "Testing NODE_URL ($url) - Attempt $attempt/$retries..." + if curl -s --head --connect-timeout 10 "$url" | head -n 1 | grep "200" >/dev/null; then + echo "NODE_URL is reachable." + return 0 + else + echo "NODE_URL ($url) is not reachable." + if [ $attempt -lt $retries ]; then + echo "Retrying in $delay seconds..." + sleep $delay + fi + ((attempt++)) + fi + done + return 1 +} + # Step 1: Prompt user to verify or update environment variables echo "Default values:" echo "- NODE_URL: $NODE_URL" @@ -54,7 +79,7 @@ fi # Check Docker daemon echo "Checking Docker daemon..." if ! docker info >/dev/null 2>&1; then - echo "Docker daemon is not running. Attempting to start..." + echo "Docker daemon is not running. Bones to start..." if command -v systemctl >/dev/null; then sudo systemctl start docker || { echo "Error: Failed to start Docker. Please start Docker manually." @@ -75,13 +100,40 @@ else fi # Step 3: Test NODE_URL connectivity -echo "Testing NODE_URL connectivity..." -if curl -s --head "$NODE_URL" | head -n 1 | grep "200" >/dev/null; then - echo "NODE_URL is reachable." -else - echo "Error: NODE_URL ($NODE_URL) is not reachable." - echo "Verify the URL at https://docs.aztec.network or ask on Aztec Discord (https://discord.gg/aztec)." - exit 1 +if ! test_node_url "$NODE_URL"; then + echo "Error: NODE_URL ($NODE_URL) is not reachable after retries." + echo "Troubleshooting steps:" + echo "1. Verify the URL at https://docs.aztec.network or ask on Aztec Discord (https://discord.gg/aztec)." + echo "2. Check if the testnet requires partner access (contact devrel@aztecprotocol.com)." + echo "3. Ensure your server allows outbound HTTP traffic to $NODE_URL." + echo " Run: curl -s --head $NODE_URL" + echo "4. Alternatively, use the Aztec Sandbox (local development environment)." + echo "Enter a new NODE_URL to try again, or type 'sandbox' to switch to the Sandbox:" + read -r fallback_url + if [ "$fallback_url" = "sandbox" ]; then + echo "Switching to Aztec Sandbox..." + export NODE_URL=$SANDBOX_NODE_URL + echo "Installing and starting Aztec Sandbox..." + aztec-up sandbox || { + echo "Error: Failed to start Aztec Sandbox. Check Docker and https://docs.aztec.network." + exit 1 + } + if ! test_node_url "$NODE_URL"; then + echo "Error: Sandbox NODE_URL ($NODE_URL) is not reachable." + echo "Ensure the Sandbox is running (aztec-up sandbox) and Docker is configured correctly." + exit 1 + fi + elif [ -n "$fallback_url" ]; then + export NODE_URL="$fallback_url" + if ! test_node_url "$NODE_URL"; then + echo "Error: New NODE_URL ($NODE_URL) is not reachable." + echo "Verify the URL or use the Sandbox. Exiting." + exit 1 + fi + else + echo "No new URL provided. Exiting." + exit 1 + fi fi # Step 4: Install Aztec CLI @@ -130,8 +182,7 @@ if aztec-wallet register-contract \ --node-url $NODE_URL \ --from my-wallet \ --alias sponsoredfpc \ - $SPONSORED_FPC_ADDRESS SponsoredFPC \ -; then + $SPONSORED_FPC_ADDRESS SponsoredFPC; then echo "Fee sponsor contract registered successfully." else echo "Error: Failed to register fee sponsor contract. Verify SPONSORED_FPC_ADDRESS ($SPONSORED_FPC_ADDRESS)." @@ -253,5 +304,5 @@ fi echo "Aztec Testnet Setup Complete!" echo "Private balance should be 8n, and public balance should be 2n." -echo "You can now explore further with the Aztec testnet!" +echo "You can now explore further with the Aztec testnet or Sandbox!" echo "For further assistance, visit https://docs.aztec.network or join the Aztec Discord (https://discord.gg/aztec)."