You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Get rid of generate-* commands on cli, in favour of `codegen` command
with optional `--ts` or `--nr` flags.
* Update docs to explain how to do a contract compilation now.
Copy file name to clipboardexpand all lines: docs/docs/dev_docs/contracts/compiling.md
+20-28
Original file line number
Diff line number
Diff line change
@@ -6,40 +6,38 @@ In this guide we will cover how to do so, both using the CLI and programmaticall
6
6
7
7
We'll also cover how to generate a helper [TypeScript interface](#typescript-interfaces) and an [Aztec.nr interface](#noir-interfaces) for easily interacting with your contract from your typescript app and from other Aztec.nr contracts, respectively.
8
8
9
-
## Compile using the CLI
9
+
## Compile using aztec-nargo
10
10
11
-
To compile a contract using the Aztec CLI, first [install it](../cli/cli-commands#installation).
11
+
To compile a contract using the Aztec's build of nargo.
12
12
13
-
Then run the `compile` command with the path to your [contract project folder](./layout.md#directory-structure), which is the one that contains the `Nargo.toml` file:
13
+
Run the `aztec-nargo compile` command within your [contract project folder](./layout.md#directory-structure), which is the one that contains the `Nargo.toml` file:
This will output a JSON [artifact](./artifacts.md) for each contract in the project to a `target` folder containing their artifact, which you can use for deploying or interacting with your contracts.
19
+
This will output a JSON [artifact](./artifacts.md) for each contract in the project to a `target` folder containing the Noir ABI artifacts.
20
20
21
-
`aztec-cli` uses `noir_wasm` by default for compiling contracts. This helps reduce the developer overhead of installation and maintaining the noir compiler, `nargo`. However, if you prefer, you can use `nargo` to compile contracts with `aztec-cli` as so:
21
+
Before you can use the ABI it currently needs to be validated as being Aztec compatible, and transformed to an Aztec compatible ABI using `aztec-cli codegen`, passing a Noir ABI file or folder, and output location, e.g:
22
22
23
23
```bash
24
-
aztec-cli compile my-contract --compiler nargo # switches compiler to nargo
When you specify `nargo` as your compiler, you need to make sure that you are using the correct version. You can find the [latest version information here](../updating.md#updating-nargo).
27
+
It can be useful to perform this compilation, validation and transformation in one go, so you may wish to chain the commands and perhaps add them to a package.json script. The below assumes your contract is in a folder called `contract` at your project root:
28
28
29
-
### Typescript Interfaces
30
-
31
-
You can use the compiler to autogenerate type-safe typescript classes for each of your contracts. These classes define type-safe methods for deploying and interacting with your contract based on their artifact.
You can use the codegenerator to autogenerate type-safe typescript classes for each of your contracts. These classes define type-safe methods for deploying and interacting with your contract based on their artifact.
38
36
39
-
You can also generate these interfaces from prebuilt artifacts using the `generate-typescript` command:
37
+
To generate them, include a `--ts` option in the codegen command with a path to the target folder for the typescript files:
Below is typescript code generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/contracts/token_contract/src/main.nr) contract:
@@ -133,16 +131,10 @@ An Aztec.nr contract can [call a function](./syntax/functions.md) in another con
133
131
134
132
To make this easier, the compiler can generate contract interface structs that expose a convenience method for each function listed in a given contract artifact. These structs are intended to be used from another contract project that calls into the current one. For each contract, two interface structs are generated: one to be used from private functions with a `PrivateContext`, and one to be used from open functions with a `PublicContext`.
135
133
136
-
To generate them, include a `--interface` option in the compile command with a path to the target folder for the generated Aztec.nr interface files:
Below is an example interface, also generated from the [Token](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/contracts/token_contract/src/main.nr) contract:
0 commit comments