-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): Edit Aztec.nr Guide section (#10866)
Updates the Aztec.nr guide section. - adds a landing page for the section - updates the page ordering to be more intuitive to how the development flow goes in practice - adds a landing page for the "writing contracts" section closes: #10523
- Loading branch information
1 parent
15e0d71
commit 4051ba8
Showing
12 changed files
with
110 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
docs/docs/guides/developer_guides/smart_contracts/index.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: Aztec.nr | ||
tags: [aztec.nr] | ||
--- | ||
|
||
import DocCardList from "@theme/DocCardList"; | ||
|
||
Aztec.nr is the smart contract development framework for Aztec. It is a set of utilities that | ||
help you write Noir programs to deploy on the Aztec network. | ||
|
||
## Contract Development | ||
|
||
### Prerequisites | ||
|
||
- Install [Aztec Sandbox and tooling](../../getting_started.md) | ||
- Install the [Noir LSP](../local_env/installing_noir_lsp.md) for your editor. | ||
|
||
### Flow | ||
|
||
1. Write your contract and specify your contract dependencies. Every contract written for Aztec will have | ||
aztec-nr as a dependency. Add it to your `Nargo.toml` with | ||
|
||
```toml | ||
# Nargo.toml | ||
[dependencies] | ||
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="noir-projects/aztec-nr/aztec" } | ||
``` | ||
|
||
2. [Write your contracts](./writing_contracts/index.mdx). | ||
3. [Profile](./profiling_transactions.md) the private functions in your contract to get | ||
a sense of how long generating client side proofs will take | ||
4. Write unit tests [using the TXE](testing.md) and end-to-end | ||
tests [with typescript](../js_apps/test.md) | ||
5. [Compile](how_to_compile_contract.md) your contract | ||
6. [Deploy](how_to_deploy_contract.md) your contract | ||
|
||
## Section Contents | ||
|
||
<DocCardList /> |
4 changes: 1 addition & 3 deletions
4
docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
docs/docs/guides/developer_guides/smart_contracts/testing_contracts/_category_.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../guides/developer_guides/smart_contracts/writing_contracts/how_to_emit_event.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: Emitting Events | ||
sidebar_position: 3 | ||
sidebar_position: 4 | ||
tags: [contracts] | ||
--- | ||
|
||
|
47 changes: 47 additions & 0 deletions
47
docs/docs/guides/developer_guides/smart_contracts/writing_contracts/index.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Writing Contracts | ||
tags: [aztec.nr] | ||
--- | ||
|
||
import DocCardList from "@theme/DocCardList"; | ||
|
||
## Overview | ||
|
||
To write a contract: | ||
|
||
1. Import aztec.nr and declare your contract | ||
|
||
```rust | ||
#include_code declaration /noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr raw | ||
|
||
// Imports | ||
|
||
// Storage | ||
|
||
// Functions | ||
} | ||
``` | ||
|
||
2. Define imports in your contract block | ||
|
||
#include_code imports /noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr rust | ||
|
||
3. Declare your contract storage below your imports | ||
|
||
#include_code storage_struct /noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr rust | ||
|
||
4. Declare a constructor with `#[initializer]`. Constructors can be private or public functions. | ||
|
||
#include_code constructor /noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr rust | ||
|
||
5. Declare your contract functions | ||
|
||
#include_code cast_vote /noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr rust | ||
|
||
There is a lot more detail and nuance to writing contracts, but this should give you a good starting point. | ||
Read contents of this section for more details about authorizing contract to act on your behalf (authenticaion witnesses), | ||
emitting events, calling functions on other contracts and other common patterns. | ||
|
||
## Section Contents | ||
|
||
<DocCardList /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
docs/docs/guides/developer_guides/smart_contracts/writing_contracts/notes/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: Notes | ||
sidebar_position: 6 | ||
sidebar_position: 3 | ||
tags: [contracts, notes] | ||
--- | ||
|
||
Notes are the fundamental data structure in Aztec when working with private state. In this section there are guides about how to work with `AddressNote`, `ValueNote`, and custom notes in Aztec.nr. You can learn more about notes in the [concepts section](../../../../../aztec/concepts/storage/state_model/index.md#private-state). | ||
Notes are the fundamental data structure in Aztec when working with private state. In this section there are guides about how to work with `AddressNote`, `ValueNote`, and custom notes in Aztec.nr. You can learn more about notes in the [concepts section](../../../../../aztec/concepts/storage/state_model/index.md#private-state). |
1 change: 1 addition & 0 deletions
1
...docs/guides/developer_guides/smart_contracts/writing_contracts/storage/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: Declaring Storage | ||
sidebar_position: 2 | ||
tags: [contracts, storage] | ||
--- | ||
|
||
|