Nargo
nargo
is a command line tool for interacting with Noir programs (e.g. compiling, proving,
verifying and more).
Alternatively, the interactions can also be performed in TypeScript.
Installation
There are three approaches to install Nargo:
Optionally you can also install Noir VS Code extension for syntax highlighting.
Option 1: Noirup
If you're on OSX or Linux, the easiest way to start using Noir and Nargo is via noirup. Just open a terminal and run:
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
Close the terminal, open another one, and run
noirup
Done, you should have the correct version working. You can also install nightlies, specific versions or branches, check out the noirup repository for more information
GitHub Actions
You can use noirup
with GitHub Actions for CI/CD and automated testing. It is as simple as
installing noirup
and running tests in your GitHub Action yml
file.
See the config file in this repo containing hash functions in Noir for an example.
Option 2: Binaries
See GitHub Releases for the latest and previous platform specific binaries.
Step 1
Paste and run the following in the terminal to extract and install the binary:
macOS / Linux: If you are prompted with
Permission denied
when running commands, prependsudo
and re-run it.
macOS (Apple Silicon)
mkdir -p $HOME/.nargo/bin && \
curl -o $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.4.1/nargo-aarch64-apple-darwin.tar.gz && \
tar -xvf $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \
echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \
source ~/.zshrc
macOS (Intel)
mkdir -p $HOME/.nargo/bin && \
curl -o $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.4.1/nargo-x86_64-apple-darwin.tar.gz && \
tar -xvf $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \
echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \
source ~/.zshrc
Windows (PowerShell)
Open PowerShell as Administrator and run:
mkdir -f -p "$env:USERPROFILE\.nargo\bin\"; `
Invoke-RestMethod -Method Get -Uri https://github.com/noir-lang/noir/releases/download/v0.4.1/nargo-x86_64-pc-windows-msvc.zip -Outfile "$env:USERPROFILE\.nargo\bin\nargo-x86_64-pc-windows-msvc.zip"; `
Expand-Archive -Path "$env:USERPROFILE\.nargo\bin\nargo-x86_64-pc-windows-msvc.zip" -DestinationPath "$env:USERPROFILE\.nargo\bin\"; `
$Reg = "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"; `
$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path; `
$NewPath = $OldPath + ’;’ + "$env:USERPROFILE\.nargo\bin\"; `
Set-ItemProperty -Path "$Reg" -Name PATH –Value "$NewPath"; `
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Linux (Bash)
mkdir -p $HOME/.nargo/bin && \
curl -o $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.4.1/nargo-x86_64-unknown-linux-gnu.tar.gz && \
tar -xvf $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -C $HOME/.nargo/bin/ && \
echo -e '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.bashrc && \
source ~/.bashrc
Step 2
Check if the installation was successful by running nargo --help
.
macOS: If you are prompted with an OS alert, right-click and open the nargo executable from Finder. Close the new terminal popped up and
nargo
should now be accessible.
For a successful installation, you should see something similar to the following after running the command:
$ nargo --help
Noir's package manager
Usage: nargo <COMMAND>
Commands:
check Checks the constraint system for errors
codegen-verifier Generates a Solidity verifier smart contract for the program
compile Compile the program and its secret execution trace into ACIR format
new Create a new binary project
execute Executes a circuit to calculate its return value
prove Create proof for this program. The proof is returned as a hex encoded string
verify Given a proof and a program, verify whether the proof is valid
test Run the tests for this program
gates Counts the occurrences of different gates in circuit
help Print this message or the help of the given subcommand(s)
Option 3: Compile from Source
Setup
Download Noir's source code from Github by running:
git clone [email protected]:noir-lang/noir.git
Change directory into the Noir project and checkout the v0.4.1 release by running:
cd noir && git checkout tags/v0.4.1
Note that you can install the latest version by building the project directly from the master
branch, but this may not work as expected or may include undocumented features since it is not an
official release.
There are then two approaches to proceed, differing in how the proving backend is installed:
Option 2.1: Install Executable with WASM backend
Install Nargo by running:
cargo install --locked --path=crates/nargo_cli --no-default-features --features plonk_bn254_wasm
Option 2.2: Install Executable with Native Backend
The barretenberg proving backend is written in C++, hence compiling it from source would first require certain dependencies to be installed.
macOS
Installing through Homebrew is recommended:
brew install cmake llvm libomp
Ubuntu (Linux)
sudo apt update && sudo apt install clang lld cmake libomp-dev
Other variants of Linux will need to adjust the commands for their package manager.
Windows
TBC
Install Nargo by running:
cargo install --locked --path=crates/nargo_cli
Verify Installation
Check if the installation was successful by running
nargo --version
:$ nargo --version
nargo 0.4.1 (git version hash: 29b1f7df4d563849a62e64c533cb62932188135b, is dirty: false)