leo add
The leo add command is used to add a new on-chain, local, workspace, or git dependency to the current Leo project.
To add a local dependency to your project, run the following command:
leo add --local <LOCAL> <NAME>
where <NAME> is the name of the imported program or library, and <LOCAL> is the path to the local project or library.
To add a program already deployed onchain as a dependency to your project, run the following command:
leo add <NAME> --network
<NAME> is the name of the imported program. Leo makes sure that the program exists before it changes program.json.
To add another member of the enclosing workspace as a dependency:
leo add --workspace <NAME>
where <NAME> is the directory name or program name of the workspace member.
To add a dependency from a git repository:
leo add --git <URL> <NAME>
where <NAME> is the name of the imported program or library, and <URL> is the repository URL. Optionally pin to a branch, tag, or revision with --branch, --tag, or --rev.
Libraries can only be added as local or git dependencies. Use --local or --git to add a library.
Flags
--local <LOCAL>
-l <LOCAL>
Specifies a local program or library dependency at <LOCAL>. The path can be a Leo project root, a Leo library root, or a compiled .aleo file.
--network
-n
Specifies that the dependency to be added is a remote program currently deployed onchain. The network that it will be pulled from will be the same as the one specified in by the NETWORK variable in .env
--endpoint <ENDPOINT>
Use this option to specify the endpoint that Leo uses to verify a network dependency. This option overrides the ENDPOINT environment variable.
--network-retries <N>
Use this option to specify how many times Leo retries a network request. This option overrides the NETWORK_RETRIES environment variable. The default value is 2.
--workspace
-w
Specifies that the dependency is another member of the enclosing workspace. Leo validates that a workspace.json exists in a parent directory and that the named member is listed in it. No path is required - Leo resolves the member's location automatically.
--git <URL>
-g <URL>
Specifies that the dependency is fetched from the git repository at <URL> (a Leo program, a Leo library, or a compiled .aleo file). Leo clones the repository to read its manifest and auto-detect the package kind, and records the resolved commit in leo.lock. See Git Dependencies.
--branch <BRANCH> / --tag <TAG> / --rev <REV>
Pin a git dependency to a specific branch, tag, or revision. These require --git, and at most one may be given. When none is specified, the repository's default branch is tracked.
--edition <EDITION>
-e <EDITION>
Specifies the expected edition of the program being imported. Only passing this flag will assume that the program is being imported from the network.
Do not use this feature unless you know what you are doing!
--dev
Specifies that the imported program is a development dependency and should not be used in production