/aztec-gravix

Primary LanguageTypeScript

This is a minimal Aztec Noir smart contract and frontend bootstrapped with aztec-cli unbox. It is recommended you use the aztec-cli unbox blank-react 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:

yarn
yarn install:noir
yarn install:sandbox

This sandbox requires Docker to be installed and running locally. In the event the image needs updating, you can run yarn install:sandbox (see sandbox docs for more information.)

In addition to the usual javascript dependencies, this project requires nargo (package manager) and noir (Aztec ZK smart contract language) in addition to @aztec/aztec-cli. The former two are installed by 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 should provide a minimal smart contract frontend.

This folder should have the following directory structure:

|— README.md
|— package.json
|— src
       |-config.ts - Blank Contract specific configuration for the frontend.
       |             You may need to update this if you modify the contract functions.
       |— app
              |— [frontend React .tsx code files]
       |- scripts
              |- [helpers for frontend to interact with contract on the sandbox]
       |— 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 Blank contract deploys on a local sandbox
              | The test requires the sandbox and anvil to be running (`yarn start:sandbox`).
              | You can run the tests with `yarn test:integration`
              |- 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

yarn compile

This will generate a Contract ABI and TypeScript class for the Aztec smart contract, 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 artifacts, so they should update automatically after you recompile.

Learn More

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

Deploy on Aztec3

Coming Soon :)