Aztec.nr
What is Aztec.nr?
Aztec.nr is a framework for writing Aztec smart contracts.
Nomenclature
Noir is a domain specific language for creating and verifying proofs. It's design choices are influenced heavily by Rust.
A smart contract is just a collection of persistent state variables, and a collection of functions which may edit those state variables.
An Aztec smart contract is a smart contract with private state variables and private functions.
Aztec.nr is a framework for writing Aztec smart contracts, written in Noir.
Getting started
Install Noir
To write an Aztec.nr contract, you need to write Noir, aztec-cli comes with a built-in compiler for Noir contracts.
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 nargo
(recommended)
The CLI comes with the Noir compiler, so installing nargo
is not required, however it is recommended as it provides a better developer experience for writing contracts. You will need nargo installed to take advantage of the Noir Language Server, which provides syntax highlighting and formatting for your Aztec contracts.
You will also need nargo
if you want to run unit tests in Noir.
You can install nargo
with the following commands:
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup -v v0.18.0-aztec.5
Install Noir tooling
There are a number of tools to make writing Aztec.nr contracts more pleasant. See here.
Tutorials
See the Token Contract tutorial for more info on getting set up to write contracts.
Learn more
📄️ Contract Workflow
Setup
📄️ Setup
Introduction
📄️ Structure
A contract is a collection of persistent state variables, and functions which may manipulate these variables. Functions and state variables within a contract's scope are said to belong to that contract. A contract can only access and modify its own state. If a contract wishes to access or modify another contract's state, it must make a call to an external function of the other contract. For anything to happen on the Aztec network, an external function of a contract needs to be called.
🗃️ Syntax
5 items
📄️ Compiling contracts
Once you have written a contract in Aztec.nr, you will need to compile it into an artifact in order to use it.
📄️ Deploying contracts
Once you have compiled your contracts you can proceed to deploying them using the aztec-cli or using aztec.js which is a Typescript client to interact with the sandbox.
📄️ Contract artifacts
After compiling a contract you'll get a Contract Artifact file, that contains the data needed to interact with a specific contract, including its name, functions that can be executed, and the interface and code of those functions. Since private functions are not published in the Aztec network, you'll need this artifact file to be able to call private functions of contracts.
🗃️ Portals
4 items
🗃️ Resources
2 items