Skip to content

Commit

Permalink
Merge branch 'master' into rk/fix_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
critesjosh committed Sep 21, 2023
2 parents e9ca6e4 + 7d315cd commit 3a08982
Show file tree
Hide file tree
Showing 8 changed files with 528 additions and 343 deletions.
11 changes: 8 additions & 3 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ int main(int argc, char* argv[])
std::string vk_path = getOption(args, "-k", "./target/vk");
CRS_PATH = getOption(args, "-c", "./crs");
bool recursive = flagPresent(args, "-r") || flagPresent(args, "--recursive");

// Skip CRS initialization for any command which doesn't require the CRS.
if (command == "info") {
std::string output_path = getOption(args, "-o", "info.json");
acvmInfo(output_path);
return 0;
}

init();

if (command == "prove_and_verify") {
Expand All @@ -355,9 +363,6 @@ int main(int argc, char* argv[])
} else if (command == "vk_as_fields") {
std::string output_path = getOption(args, "-o", vk_path + "_fields.json");
vkAsFields(vk_path, output_path);
} else if (command == "info") {
std::string output_path = getOption(args, "-o", "info.json");
acvmInfo(output_path);
} else {
std::cerr << "Unknown command: " << command << "\n";
return 1;
Expand Down
29 changes: 25 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ Most changes are reflected live without having to restart the server.
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
This command generates static content into the `build` directory and can be served using any static contents hosting service. When run on Netlify, it will also build the typescript projects needed for extracting type information via typedoc.


## #include_code macro
## Macros

### `#include_code`

You can embed code snippets into a `.md`/`.mdx` file from code which lives elsewhere in the repo.
- In your markdown file:
Expand Down Expand Up @@ -119,7 +121,26 @@ You can embed code snippets into a `.md`/`.mdx` file from code which lives elsew
- `#include_code hello path/from/repo/root/to/file.ts typescript noTitle,noLineNumbers,noSourceLink`
- Ironically, we can't show you a rendering of these examples, because this README.md file doesn't support the `#include_code` macro!

> See [here](./src/components/GithubCode/index.js) for another way to include code, although this approach is flakier, so the above `#include_code` macro is preferred.

### `#include_aztec_version`

This macros will be replaced inline with the current aztec packages tag, which is `aztec-packages-v0.7.10` at the time of these writing. This value is sourced from `.release-please-manifest.json` on the project root.

### Another way to include code.
Alternatively, you can also use the `AztecPackagesVersion()` js function, which you need to import explicitly:

```
import { AztecPackagesVersion } from "@site/src/components/Version";
<>{AztecPackagesVersion()}</>
```
See [here](./src/components/GithubCode/index.js), although this approach is flakier, so the above `#include_code` macro is preferred.
### `#include_noir_version`
This macros will be replaced inline with the required nargo version, which is `0.11.1-aztec.0` at the time of these writing. This value is sourced from `yarn-project/noir-compiler/src/noir-version.json`.
Alternatively, you can also use the `NoirVersion()` js function, which you need to import explicitly:
```
import { NoirVersion } from "@site/src/components/Version";
<>{NoirVersion()}</>
```
88 changes: 88 additions & 0 deletions docs/docs/dev_docs/getting_started/noir_contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Aztec.nr Contracts Quickstart
---

## Introduction

This guide explains the set up required to write a contract using the Aztec.nr library; then deploy it to the sandbox. Aztec.nr is a library on top of [Noir](https://noir-lang.org/) that can be used to write smart contracts for Aztec. Since Noir files use the `.nr` extension, we are calling this library "Aztec.nr".

:::info Prerequisite reading
If you haven't read [Aztec Sandbox](./sandbox.md), we recommend going there first.
:::

### Dependencies

#### `nargo`

Nargo is Noir's build tool. On your terminal, run:

<InstallNargoInstructions />

#### Aztec Sandbox

You need to setup the [Aztec sandbox](./sandbox.md).

<!-- TODO([#1056](https://github.com/AztecProtocol/aztec-packages/issues/1056)): Add a step for the starter kit -->

## Set up for aztec.nr contracts

1. Inside the yarn project you created from the [Aztec.js](./sandbox.md) page, create a sub-folder where the contracts will reside.

```bash
mkdir contracts
```

All contract projects will reside within this folder. Note that contracts don't actually have to live here and this is just a style choice.

2. Next, create a noir project using nargo by running the following in the terminal from the `contracts` folder

```bash
cd contracts
nargo new example_contract
```

This creates a noir project with a Nargo.toml (which is the manifest file of the project). This file is found at `example_contract/src/main.nr`, where we will write our contract.

Your folder should look like:

```
.
|-contracts
| |--example_contract
| | |--src
| | | |--main.nr
|-src
| |--index.ts
```

Before writing the contracts, we must add the aztec.nr library. This adds smart contract utility functions for interacting with the Aztec network.

3. Add aztec.nr library as a dependency to your noir project. Open Nargo.toml that is in the `contracts/example_contract` folder, and add the dependency section as follows:

```toml
[package]
name = "example_contract"
authors = [""]
compiler_version = "0.1"
type = "contract"

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

:::note
You may need to update your dependencies depending on the contract that you are writing. For example, the token contract [imports more](../getting_started/token_contract_tutorial#project-setup).
:::

You are now ready to write your own contracts!

You can replace the content of the generated file `example_contract/src/main.nr` with your contract code.

## Next Steps

- You can learn more about writing contracts from the [Contracts section](../contracts/main.md).
- You can find more example Aztec contracts [here](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/src/contracts).
- Consider going through the [token contract tutorial](./token_contract_tutorial.md) for a deep dive on writing more advanced Aztec contracts and an introduction to some of the concepts that underpin the Aztec network architecture.
- After writing the contract, you have to compile it. Details can be found [here](../contracts/compiling.md).
- After compiling, you can deploy your contract to the Aztec network. Relevant instructions and explanations can be found [here](../contracts/deploying.md).
- Thereafter, you can interact with the contracts similar to how it was shown in the the [Creating and submitting transactions section on the Sandbox page](./sandbox.md#creating-and-submitting-transactions).
13 changes: 6 additions & 7 deletions docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ nargo new --contract token

Then, open the `contracts/token/Nargo.toml` configuration file, and add the `aztec.nr` and `value_note` libraries as dependencies:

import { AztecPackagesVersion } from "@site/src/components/Version";

<CodeBlock language="toml">{`[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/value-note"}
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/safe-math"}
`}</CodeBlock>
```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"}
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/safe-math"}
```

Last, copy-paste the code from the `Token` contract into `contracts/token/main.nr`:

Expand Down
15 changes: 7 additions & 8 deletions docs/docs/dev_docs/tutorials/writing_token_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,18 @@ Your project should look like this:

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

import { AztecPackagesVersion } from "@site/src/components/Version";

<CodeBlock language="toml">{`[package]
```toml
[package]
name = "token_contract"
authors = [""]
compiler_version = "0.1"
type = "contract"

[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/value-note"}
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/safe-math"}
`}</CodeBlock>
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"}
```

## Contract Interface

Expand Down
Loading

0 comments on commit 3a08982

Please sign in to comment.