Skip to content

Commit 5ccfb4d

Browse files
authored
Merge pull request #480 from ProvableHQ/rr-update-dependency-guide
Leo dependency guide
2 parents 88a3874 + dd8c5f4 commit 5ccfb4d

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

documentation/cli/04_dependencies.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,81 @@ id: dependencies
33
title: Dependency Management
44
sidebar_label: Dependency Management
55
---
6-
<!--TODO:-->
6+
## Leo imports
7+
In your `main.leo` file, specify any imported dependencies using the `import` keyword before the program declaration:
8+
```leo
9+
import credits.aleo;
710
8-
Coming soon!
11+
program test.aleo {
12+
...
13+
}
14+
```
15+
16+
From the root of your Leo program directory, use the `leo add` command to update the `program.json` manifest to add dependencies.
17+
18+
## Deployed Programs
19+
When adding a deployed program as a dependency to your program, such as the `credits.aleo`, use the following command::
20+
21+
```
22+
leo add credits.aleo
23+
```
24+
or
25+
```
26+
leo add credits
27+
```
28+
29+
If you are deplolying to mainnet, you will need to specify mainnet imports using the `--network` flag as follows:
30+
31+
```
32+
leo add credits --network mainnet
33+
```
34+
35+
For the first imported dependency, a new `dependencies` field will be added to the 'package.json` manifest:
36+
37+
```json
38+
{
39+
"program": "your_program.aleo",
40+
"version": "0.0.0",
41+
"description": "",
42+
"license": "MIT",
43+
"dependencies": [
44+
{
45+
"name": "credits.aleo",
46+
"location": "network",
47+
"network": "testnet",
48+
"path": null
49+
}
50+
]
51+
}
52+
```
53+
54+
## Local development
55+
When deploying to a local devnet, specify the path for the local dependency as follows:
56+
57+
```
58+
leo add program_name.aleo --local ./path_to_dependency
59+
```
60+
The dependencies section in the `program.json` manifest should include the path:
61+
```json
62+
{
63+
"program": "your_program.aleo",
64+
"version": "0.0.0",
65+
"description": "",
66+
"license": "MIT",
67+
"dependencies": [
68+
{
69+
"name": "local_dependency.aleo",
70+
"location": "local",
71+
"network": null,
72+
"path": "./path"
73+
}
74+
]
75+
}
76+
```
77+
78+
## Deploying to a program with local dependencies to a network.
79+
When deploying a program that uses local dependcies, use the following command:
80+
```bash
81+
leo deploy --recursive
82+
```
83+
All local dependency will be deployed in order, followed by the main program. Deployed dependencies will be skipped.

0 commit comments

Comments
 (0)