Skip to content

## Add Dockerfile and Update README for Aztec Testnet Setup #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
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
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Base image
FROM ubuntu:22.04

# Install system dependencies
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 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 CLI (no daemon)
RUN apt-get update && apt-get install -y \
docker-ce-cli \
containerd.io \
&& rm -rf /var/lib/apt/lists/*

# Copy setup script
COPY aztec-testnet-setup.sh /aztec-testnet-setup.sh

# Make it executable
RUN chmod +x /aztec-testnet-setup.sh

# Set working directory
WORKDIR /

# Run the script when container starts
CMD ["/bin/bash", "/aztec-testnet-setup.sh"]
153 changes: 31 additions & 122 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,138 +1,47 @@
<div align="center">
<a href="https://aztec.network">
<img src="https://github.com/AztecProtocol/aztec-packages/blob/master/docs/static/img/aztec-logo.9cde8ae1.svg" alt="Aztec Protocol Logo" width="300">
</a>
</div>

# 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.

<div align="center">

[![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)

</div>

---

## 🚀 **Getting Started**

Use **Node.js version 18.19.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:

```bash
bash -i <(curl -s https://install.aztec.network)
```

Install the correct version of the toolkit with:

```bash
aztec-up 0.86.0
```

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:
# Aztec Testnet Setup Guide

```bash
yarn test
```
This repository provides a script to automate the setup and interaction with the Aztec testnet using a single command in a Docker container.

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;`).
## Prerequisites
- Docker installed on your machine.

Note: The Typescript tests spawn an instance of the sandbox to test against, and close it once the TS tests are complete.
## you can setup this guide using codespace
- https://github.com/codespaces

---
## Usage
1. Clone the repository:
```bash
git clone https://github.com/Gmhax/aztec-starter.git
cd aztec-starter
```

## ❗ **Error Resolution**
- Build the Docker image
```bash
docker build -t aztec-testnet .
```

### 🔄 **Update Node.js and Noir Dependencies**
- Run the Docker container:
```bash
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /root \
aztec-testnet
```

```bash
yarn update
```
- Follow the output to see the setup process, including account creation, contract deployment, token minting, and balance checking.

### 🔄 **Update Contract**
## Expected Output
- Private balance: 8n
- Public balance: 2n

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.
## 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.](https://docs.aztec.network/developers/guides/getting_started_on_testnet)

```bash
yarn update
```

You may need to update permissions with:

```bash
chmod +x update_contract.sh
```

### 💬 Join the Community:

Expand Down
Loading