Skip to main content
Version: 0.5.1

Managing Dependencies

Nargo allows you to upload packages to GitHub and use them as dependencies.

Specifying a dependency

Specifying a dependency requires a tag to a specific commit and the git url to the url containing the package.

Currently, there are no requirements on the tag contents. If requirements are added, it would follow semver 2.0 guidelines.

Note: Without a tag , there would be no versioning and dependencies would change each time you compile your project.

For example, to add the ecrecover-noir library to your project, add it to Nargo.toml:

# Nargo.toml

ecrecover = {tag = "v0.2.0", git = ""}

Specifying a local dependency

You can also specify dependencies that are local to your machine.

For example, this file structure has a library and binary crate

├── binary_crate
│   ├── Nargo.toml
│   └── src
│   └──
└── liba
├── Nargo.toml
└── src

Inside of the binary crate, you can specify:

# Nargo.toml

libA = { path = "../liba" }

Importing dependencies

You can import a dependency to a Noir file using the following syntax. For example, to import the ecrecover-noir library and local liba referenced above:

use dep::ecrecover;
use dep::libA;

You can also import only the specific parts of dependency that you want to use. For example, demonstrated in the elliptic curve example, you can import just the Point and the Curve that you want to use.

use dep::std::ec::tecurve::affine::Curve;
use dep::std::ec::tecurve::affine::Point;