Skip to content
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

docs: update docs #3223

Merged
merged 23 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
46 changes: 7 additions & 39 deletions docs/docs/dev_docs/cli/updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,24 @@ title: Updating

## Quick Reference

- Aztec Sandbox
Inside your project run:

```shell
/bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')"
cd your/aztec/project
npx @aztec/cli@latest update . --contract src/contract1 --contract src/contract2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexghr the sandbox has to running for this command to work, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two possibilities:

  1. if the project has @aztec/aztec-sandbox listed as a dependency in package.json then it will compare against that version
  2. otherwise it grabs the version of the running sandbox. If sandbox isn't running it exits and prints the error message:
Could not connect to Sandbox running on <url>

```

- Aztec CLI

```shell
npm install -g @aztec/cli
```

- nargo

```shell
noirup
```

- Aztec.nr

```toml
#nargo.toml
[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note" }
```
This will update `@aztec/*` dependencies in `package.json` as well as Aztec.nr libraries in `Nargo.toml` to the latest version. If `@aztec/sandbox` and `@aztec/cli` are listed as dependencies then they will be automatically updated as well.

Read on to learn about versioning and other commands.

There are 4 components whose versions need to be kept compatible:
There are three components whose versions need to be kept compatible:

1. Aztec Sandbox,
2. Aztec CLI,
3. Noir compiler `nargo`,
4. Noir framework for Aztec contracts `aztec.nr`.
3. Noir framework for Aztec contracts `aztec.nr`.

Aztec Sandbox, Aztec CLI and `aztec.nr` are using the same versioning scheme and their versions must match.
The Noir compiler `nargo` has its own versioning scheme and its version must match the compatible nargo version specified in Sandbox.
All three are using the same versioning scheme and their versions must match.

## Updating Aztec Sandbox

Expand Down Expand Up @@ -100,18 +80,6 @@ E.g.:
npm install -g @aztec/cli@#include_aztec_short_version
```

## Updating Noir compiler

Now we need to update the Noir compiler `nargo` to the version compatible with the sandbox.
Use `aztec-cli` to get it:
#include_code node-info yarn-project/end-to-end/src/cli_docs_sandbox.test.ts bash

Then we install the `Compatible Nargo Version` with (replace `COMPATIBLE_NARGO_VERSION` with the version from the previous command):

```shell
noirup -v COMPATIBLE_NARGO_VERSION
```

## Updating Aztec.nr packages

Finally we need to update the Noir framework for Aztec contracts.
Expand Down
13 changes: 2 additions & 11 deletions docs/docs/dev_docs/contracts/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ In this guide we will cover how to do so, both using the CLI and programmaticall

We'll also cover how to generate a helper [TypeScript interface](#typescript-interfaces) and an [Aztec.nr interface](#noir-interfaces) for easily interacting with your contract from your typescript app and from other Aztec.nr contracts, respectively.

## Prerequisites

You will need the Noir build tool `nargo`, which you can install via [`noirup`](https://github.com/noir-lang/noirup). Make sure you install the correct version of nargo:

<InstallNargoInstructions />

:::info
You can run `aztec-cli get-node-info` to query the version of nargo that corresponds to your current installation.
:::

## Compile using the CLI

To compile a contract using the Aztec CLI, first install it:
Expand Down Expand Up @@ -247,7 +237,8 @@ You can also programmatically access the compiler via the `@aztec/noir-compiler`

The compiler exposes the following functions:

- `compileUsingNargo`: Compiles an Aztec.nr project in the target folder using the `nargo` binary available on the shell `PATH` and returns the generated ABIs.
- `compileUsingNoirWasm`: Compiles an Aztec.nr project in the target folder using a WASM build of the compiler and returns the generated ABIs.
- `compileUsingNargo`: Does the same as `compileUsingNargo` but instead of WASM it uses the `nargo` binary available on the shell `PATH`
- `generateTypescriptContractInterface`: Generates a typescript class for the given contract artifact.
- `generateNoirContractInterface`: Generates a Aztec.nr interface struct for the given contract artifact.

Expand Down
8 changes: 5 additions & 3 deletions docs/docs/dev_docs/contracts/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ Pre-requisite - Generate type-safe typescript classes for your contract when com

```ts
import { readFileSync, writeFileSync } from "fs";
import { createConsoleLogger } from "@aztec/foundation/log";
import {
compileUsingNargo,
compileUsingNoirWasm,
generateTypescriptContractInterface,
} from "@aztec/noir-compiler";

const compiled: ContractArtifact[] = await compileUsingNargo(
projectPathToContractFolder
const compiled: ContractArtifact[] = await compileUsingNoirWasm(
projectPathToContractFolder,
{ log: createConsoleLogger() }
);
const abiImportPath = "../target/Example.json";
writeFileSync(
Expand Down
6 changes: 2 additions & 4 deletions docs/docs/dev_docs/contracts/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ An **Aztec smart contract** is a smart contract with **private** state variables

## Install Noir

To write an Aztec.nr contract, you need to write Noir, which requires a build tool called Nargo:

<InstallNargoInstructions />
To write an Aztec.nr contract, you need to write Noir, [aztec-cli](../cli/cli-commands) comes with a built-in compiler for Noir contracts.

:::info
For those coming from vanilla Noir, the nargo version used for aztec.nr is tracked seaprately to nargo for vanilla noir, so be sure to use the nargo version shown above
For those coming from vanilla Noir, the version used for aztec.nr is tracked separately to nargo for vanilla noir, so be sure to use the nargo version shown above
:::

## Install Noir tooling
Expand Down
61 changes: 13 additions & 48 deletions docs/docs/dev_docs/getting_started/aztecnr-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,7 @@ If you already have some experience with Noir and want to build a cooler contrac

## Install nargo
critesjosh marked this conversation as resolved.
Show resolved Hide resolved

`Aztec.nr` is a framework built on top of [Noir](https://noir-lang.org), a zero-knowledge DSL. Nargo is the build tool for Noir, similar to cargo for Rust. We need it for compiling our smart contracts.

<InstallNargoInstructions />

You can check it has been installed correctly by running:

```bash
aztec-cli get-node-info
```

It should print something similar to:

```bash
➜ ~ aztec-cli get-node-info

Node Info:

Version: 1
Chain Id: 31337
Rollup Address: 0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9
Client: [email protected]
Compatible Nargo Version: 0.16.0-aztec.0
```
`Aztec.nr` is a framework built on top of [Noir](https://noir-lang.org), a zero-knowledge DSL. [Aztec CLI](../cli/main.md) comes with a built-in Noir compiler.

## Set up a project

Expand All @@ -52,29 +30,21 @@ cd aztec-private-counter
mkdir contracts
```

Inside `contracts`, create a new Noir project using nargo:
Inside contracts create the following file structure:

```bash
cd contracts
nargo new counter --contract
```

The `contract` flag will create a contract nargo project rather than using vanilla Noir.

Your file structure should look like this:

```bash
aztec-private-counter
|-contracts
| |--counter
| | |--src
| | | |--main.nr
| | |Nargo.toml
```tree
.
|-aztec-private-counter
| |-contracts
| | |--counter
| | | |--src
| | | | |--main.nr
| | | |--Nargo.toml
```

The file `main.nr` will soon turn into our smart contract!

Your `Nargo.toml` file should look something like this:
Add the following content to `Nargo.toml`:

```toml
[package]
Expand All @@ -84,19 +54,14 @@ authors = [""]
compiler_version = "0.16.0"
critesjosh marked this conversation as resolved.
Show resolved Hide resolved

[dependencies]
```

Add the following dependencies under `[dependencies]`:

```toml
aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
easy_private_state = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/easy-private-state"}
```

## Define the functions

Go to `main.nr` and replace the code with this contract initialization:
Go to `main.nr` and start with this contract initialization:

```rust
contract Counter {
Expand Down Expand Up @@ -157,7 +122,7 @@ We have annotated this and other functions with `#[aztec(private)]` which are AB

## Incrementing our counter

Now let’s implement the `increment` functio we defined in the first step.
Now let’s implement the `increment` function we defined in the first step.

#include_code increment /yarn-project/noir-contracts/src/contracts/counter_contract/src/main.nr rust

Expand Down
32 changes: 11 additions & 21 deletions docs/docs/dev_docs/tutorials/token_portal/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this step, we’re going to

1. Install prerequisites
2. Create a yarn project to house everything
3. Create a nargo project for our Aztec contract
3. Create a noir project for our Aztec contract
4. Create a hardhat project for our Ethereum contract(s)
5. Import all the Ethereum contracts we need
6. Create a yarn project that will interact with our contracts on L1 and the sandbox
Expand All @@ -20,18 +20,12 @@ However if you’d rather skip this part, our dev-rels repo contains the starter
- [node v18+](https://github.com/tj/n)
- [docker](https://docs.docker.com/)
- [Aztec sandbox](https://docs.aztec.network/dev_docs/getting_started/sandbox) - you should have this running before starting the tutorial
- [Aztec CLI](../../getting_started/quickstart.md)

```bash
/bin/sh -c "$(curl -fsSL 'https://sandbox.aztec.network')"
```

- Nargo

```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | sh
noirup -v #include_noir_version
```

# Create the root project and packages

Our root project will house everything ✨
Expand All @@ -43,19 +37,11 @@ cd aztec-token-bridge && mkdir packages

We will hold our projects inside of `packages` to follow the design of the project in the [repo](https://github.com/AztecProtocol/dev-rel/tree/main/tutorials/token-bridge-e2e).

# Create a nargo project
# Create a noir project

Now inside `packages` create a new directory called `aztec-contracts`

Inside `aztec-contracts`, create a nargo contract project by running

```bash
mkdir aztec-contracts
cd aztec-contracts
nargo new --contract token_bridge
```

Your structure will look something like this
Inside `aztec-contracts`, create the following file structure:

```
aztec-contracts
Expand All @@ -65,17 +51,21 @@ aztec-contracts
├── main
```

Inside `Nargo.toml` you will need to add some dependencies. Put this at the bottom:
Inside `Nargo.toml` add the following content:

```toml
[package]
name = "token_bridge"
authors = [""]
compiler_version = ">=0.18.0"
type = "contract"

[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/safe-math"}
```

Inside `src` you will see a `main.nr` file. This is where our main smart contract will go.

We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this:

```
Expand Down
34 changes: 3 additions & 31 deletions docs/docs/dev_docs/tutorials/writing_token_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,7 @@ We are going to start with a blank project and fill in the token contract source

## Requirements

You will need to install nargo, the Noir build too. if you are familiar with Rust, this is similar to cargo.

<InstallNargoInstructions />

If you've already installed the `aztec-cli`, as described in the quickstart [here](../getting_started/quickstart.md#cli), you can check which version of Noir is compatible with your version of the CLI and sandbox by running:

```bash
aztec-cli get-node-info
```

It should print something similar to:

```bash
➜ ~ aztec-cli get-node-info

Node Info:

Version: 1
Chain Id: 31337
Rollup Address: 0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9
Client: [email protected]
Compatible Nargo Version: 0.11.1-aztec.0
```
You will need to have `aztec-cli` installed in order to compile Aztec.nr contracts. See the [quickstart guide](../getting_started/quickstart.md#cli) for installation instructions.

When you are running the Sandbox, `aztec-cli`, and compiling contracts with Noir, make sure you are using matching versions--we will be shipping breaking changes so mis-matched versions may not work.

Expand All @@ -62,13 +40,7 @@ inside that directory, create a `contracts` folder for the Aztec contracts.
cd token_contract_tutorial && mkdir contracts && cd contracts
```

Create a new Noir project using nargo.

```bash
nargo new --contract token_contract
```

Your project should look like this:
Create the following file structure

```tree
.
Expand All @@ -78,7 +50,7 @@ Your project should look like this:
└── main.nr
```

Add the following dependencies to your Nargo.toml file, below the package information:
Add the following content to Nargo.toml file:

```toml
[package]
Expand Down