Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/critesjosh/blank_testing

a simple setup repo that works for testing aztec integration tests
https://github.com/critesjosh/blank_testing

Last synced: 18 days ago
JSON representation

a simple setup repo that works for testing aztec integration tests

Awesome Lists containing this project

README

        

This is a minimal [Aztec](https://aztec.network/) Noir smart contract and frontend bootstrapped with [`aztec-cli unbox`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/cli). It is recommended you use the `aztec-cli unbox blank` command so that the repository is copied with needed modifications from the monorepo subpackage.

## Setup

Dependencies can be installed from the root of the package:

```bash
yarn
yarn install:noir
yarn install:sandbox
```

This sandbox requires [Docker](https://www.docker.com/) to be installed _and running_ locally. In the event the image needs updating, you can run `yarn install:sandbox` (see [sandbox docs](https://aztec-docs-dev.netlify.app/dev_docs/getting_started/sandbox) for more information.)

In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (a Domain Specific Language for SNARK proving systems) in addition to `@aztec/aztec-cli`. The former are installed within `yarn install:noir`.

## Getting started

After `yarn` has run,`yarn start:sandbox` in one terminal will launch a local instance of the Aztec sandbox via Docker Compose and `yarn start:dev` will launch a frontend app for deploying and interacting with an empty Aztec smart contract.

At this point, [http://localhost:5173](http://localhost:5173) should provide a minimal smart contract frontend.

This folder should have the following directory structure:

```
|— README.md
|— package.json
|— src
index.html
index.ts
|— contracts
|— src
| The Noir smart contract source files are here.
|— main.nr - the cloned noir contract, your starting point
|- interface.nr - autogenerated from main.nr when you compile
|— Nargo.toml [Noir build file, includes Aztec smart contract dependencies]
|— artifacts
| These are both generated from `contracts/` by the compile command
|— blank_contract.json
|— blank.ts
|— tests
| A simple end2end test deploying and testing the minimal contract on a local sandbox
| using the front end helper methods in index.ts
| The test requires the sandbox and anvil to be running (yarn start:sandbox).
|- blank.contract.test.ts
```

Most relevant to you is likely `src/contracts/main.nr` (and the build config `src/contracts/Nargo.toml`). This contains the example blank contract logic that the frontend interacts with and is a good place to start writing Noir.

The `src/artifacts` folder can be re-generated from the command line

```bash
yarn compile
```

This will generate a [contract artifact](src/artifacts/test_contract.json) and TypeScript class for the [Aztec smart contract](src/contracts/main.nr), which the frontend uses to generate the UI.

Note: the `compile` command seems to generate a Typescript file which needs a single change -

```
import TestContractArtifactJson from 'text_contract.json' assert { type: 'json' };
// need to update the relative import to
import TestContractArtifactJson from './test_contract.json' assert { type: 'json' };
```

After compiling, you can re-deploy the updated noir smart contract from the web UI. The function interaction forms are generated from parsing the contract artifact, so they should update automatically after you recompile.

## Testing

```bash
yarn test:integration
```

## Learn More

To learn more about Noir Smart Contract development, take a look at the following resources:

- [Awesome Noir](https://github.com/noir-lang/awesome-noir) - learn about the Noir programming language.

## Deploy on Aztec3

Coming Soon :)