From 8a508e258a567d87c47f63ea3bebbe26eb54e728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Tue, 29 Aug 2023 14:03:57 +0100 Subject: [PATCH 1/4] adding some nitpick suggestions --- docs/docs/dev_docs/getting_started/cli.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/docs/dev_docs/getting_started/cli.md b/docs/docs/dev_docs/getting_started/cli.md index c7057f12241..bb0e525999f 100644 --- a/docs/docs/dev_docs/getting_started/cli.md +++ b/docs/docs/dev_docs/getting_started/cli.md @@ -4,11 +4,13 @@ title: Aztec CLI ## Introduction -The Aztec CLI is a tool designed to enable a user to interact with the Aztec Network. Here we will provide a walk-through demonstrating how to use the CLI to deploy and test contracts on the [Aztec Sandbox](../sandbox/main.md). +The Aztec CLI is a tool designed to enable a user to interact with the Aztec Network. ## Requirements -The Aztec CLI is an npm package so you will need to have installed node.js >= 18. This tutorial will use the Aztec Sandbox so you should first set up the sandbox using the link above. +This tutorial will use the Aztec Sandbox so you should first set it up by following [the Aztec Sandbox instructions](../sandbox/main.md). + +You should also have [node.js](https://nodejs.org/en/download) installed with version >= 18. To install the Aztec CLI run: @@ -76,7 +78,7 @@ Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042e Once the account is set up, the CLI returns the resulting address, its privacy key, and partial address. You can read more about these [here](../../concepts/foundation/accounts/keys.md#addresses-partial-addresses-and-public-keys). Alternatively, we can also manually generate a private key and use it for creating the account, either via a `-k` option or by setting the `PRIVATE_KEY` environment variable. - + ``` % aztec-cli generate-private-key @@ -120,7 +122,7 @@ We will now deploy the private token contract using the `deploy` command, mintin Contract deployed at 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f ``` -:::info +:::info If you use a different address in the constructor above, you will get an error when running the deployment. This is because you need to register an account in the sandbox before it can receive private notes. When you create a new account, it gets automatically registered. Alternatively, you can register an account you do not own along with its public key using the `register-recipient` command. ::: @@ -128,6 +130,7 @@ This command takes 1 mandatory positional argument which is the path to the cont Alternatively you can pass the name of an example contract as exported by `@aztec/noir-contracts` (run `aztec-cli example-contracts` to see the full list of contracts available). The command takes a few optional arguments while the most important one is: + - `--args` - Arguments to the constructor of the contract. In this case we have minted 1000000 initial tokens to the aztec address 0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c. The CLI tells us that the contract was successfully deployed. We can use the `check-deploy` command to verify that a contract has been successfully deployed to that address: @@ -184,6 +187,7 @@ We called the `transfer` function of the contract and provided these arguments: - `--args` - The list of arguments to the function call. - `--contract-abi` - The abi of the contract to call. - `--contract-address` - The deployed address of the contract to call. +- `--private-key` - The private key of the sender The command output tells us the details of the transaction such as its hash and status. We can use this hash to query the receipt of the transaction at a later time: From d1e37656329de0bcb117087f17b41eae972c6f26 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 29 Aug 2023 17:06:46 -0400 Subject: [PATCH 2/4] update bc missing page --- docs/docs/dev_docs/dapps/main.md | 7 ++++--- docs/sidebars.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/docs/dev_docs/dapps/main.md b/docs/docs/dev_docs/dapps/main.md index 65a7b601d62..cf4484cd4eb 100644 --- a/docs/docs/dev_docs/dapps/main.md +++ b/docs/docs/dev_docs/dapps/main.md @@ -4,7 +4,7 @@ Please use the [TUTORIAL-TEMPLATE](../../TUTORIAL_TEMPLATE.md) for standalone gu Explain how to write a dapp using [`aztec.js`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js). Maybe that readme is enough? -- aztec.js +- aztec.js - Docs outlining every typescript type. - Q: can we use the tsdocs, or do we need something with a human touch (i.e. with careful explanations sandwiching the auto-generated interface data?) - Docs outlining every external function: @@ -32,11 +32,12 @@ Explain how to write a dapp using [`aztec.js`](https://github.com/AztecProtocol/ - How to filter for historic data in the historic block tree? - How to query data from any of the trees (advanced) -FOR INSTRUCTIONS FOR BUILDING A WALLET, WE SHOULD WRITE DOCS [HERE](../wallets/building_a_wallet.md) +FOR INSTRUCTIONS FOR BUILDING A WALLET, WE SHOULD WRITE DOCS HERE ERRORS: + - Add any error explanations to [errors.md](../contracts/common_errors.md) (and break that file into multiple files if it's too unwieldy). ## Testing a dapp -Write about how to test a dapp using `aztec.js`. Maybe this overlaps with the e2e test stuff discussed above. \ No newline at end of file +Write about how to test a dapp using `aztec.js`. Maybe this overlaps with the e2e test stuff discussed above. diff --git a/docs/sidebars.js b/docs/sidebars.js index 46292c11f16..23f556b9ebc 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -314,7 +314,7 @@ const sidebars = { id: "dev_docs/wallets/main", }, items: [ - "dev_docs/wallets/building_a_wallet", + "dev_docs/wallets/architecture", "dev_docs/wallets/writing_an_account_contract", ], }, From 30e8a2df8a677183eef8d873a92db6a9c6f80419 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 29 Aug 2023 17:07:50 -0400 Subject: [PATCH 3/4] syntax highlighting, make command generic --- docs/docs/dev_docs/getting_started/cli.md | 75 +++++++++++++++-------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/docs/docs/dev_docs/getting_started/cli.md b/docs/docs/dev_docs/getting_started/cli.md index bb0e525999f..50af68a62b7 100644 --- a/docs/docs/dev_docs/getting_started/cli.md +++ b/docs/docs/dev_docs/getting_started/cli.md @@ -14,15 +14,21 @@ You should also have [node.js](https://nodejs.org/en/download) installed with ve To install the Aztec CLI run: -`npm install -g @aztec/cli` +```bash +npm install -g @aztec/cli +``` Or if you use yarn: -`yarn global add @aztec/cli` +```bash +yarn global add @aztec/cli +``` Then verify that it is installed with: -`aztec-cli -h` +```bash +aztec-cli -h +``` ## I have the Sandbox running, now what? @@ -30,8 +36,10 @@ Lets first establish that we are able to communicate with the Sandbox. Most comm To test communication with the Sandbox, let's run the command: -`% aztec-cli block-number -1` +```bash +% aztec-cli block-number +1 +``` You should see the current block number (1) printed to the screen! @@ -39,7 +47,7 @@ You should see the current block number (1) printed to the screen! We have shipped a number of example contracts in the `@aztec/noir-contracts` npm package. This is included with the cli by default so you are able to use these contracts to test with. To get a list of the names of the contracts run: -``` +```bash % aztec-cli example-contracts ChildContractAbi EasyPrivateTokenContractAbi @@ -65,7 +73,7 @@ In the following sections there will be commands that require contracts as optio The first thing we want to do is create a couple of accounts. We will use the `create-account` command which will generate a new private key for us, register the account on the sandbox, and deploy a simple account contract which [uses a single key for privacy and authentication](../../concepts/foundation/accounts/keys.md): -``` +```bash % aztec-cli create-account Created new account: @@ -77,9 +85,16 @@ Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042e Once the account is set up, the CLI returns the resulting address, its privacy key, and partial address. You can read more about these [here](../../concepts/foundation/accounts/keys.md#addresses-partial-addresses-and-public-keys). -Alternatively, we can also manually generate a private key and use it for creating the account, either via a `-k` option or by setting the `PRIVATE_KEY` environment variable. +Save the Address and Private key as environement variables. We will be using them later. +```bash +export ADDRESS=
+export PRIVATE_KEY= ``` + +Alternatively, we can also manually generate a private key and use it for creating the account, either via a `-k` option or by setting the `PRIVATE_KEY` environment variable. + +```bash % aztec-cli generate-private-key Private Key: 0x6622c828e9cd5adc86f10878765fe921d2b8cb2c79bdbc391157e43811ce88e3 @@ -99,7 +114,7 @@ For all commands that require a user's private key, the CLI will look for the `P Let's double check that the accounts have been registered with the sandbox using the `get-accounts` command: -``` +```bash % aztec-cli get-accounts Accounts found: @@ -112,16 +127,28 @@ Public key: 0x08aad54f32f1b6621ee5f25267166e160147cd355a2dfc129fa646a651dd2 Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed ``` +Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later. + +```bash +export ADDRESS2= +``` + ## Deploying a Token Contract We will now deploy the private token contract using the `deploy` command, minting 1000000 initial tokens to address `0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c`. Make sure to replace this address with one of the two you created earlier. -``` -% aztec-cli deploy PrivateTokenContractAbi --args 1000000 0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c +```bash +% aztec-cli deploy PrivateTokenContractAbi --args 1000000 $ADDRESS Contract deployed at 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f ``` +Save the contract address as an environment variable. We will use it later. + +```bash +export CONTRACT_ADDRESS= +``` + :::info If you use a different address in the constructor above, you will get an error when running the deployment. This is because you need to register an account in the sandbox before it can receive private notes. When you create a new account, it gets automatically registered. Alternatively, you can register an account you do not own along with its public key using the `register-recipient` command. ::: @@ -135,8 +162,8 @@ The command takes a few optional arguments while the most important one is: The CLI tells us that the contract was successfully deployed. We can use the `check-deploy` command to verify that a contract has been successfully deployed to that address: -``` -% aztec-cli check-deploy --contract-address 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f +```bash +% aztec-cli check-deploy --contract-address $CONTRACT_ADDRESS Contract found at 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f ``` @@ -145,11 +172,11 @@ Contract found at 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c0 When we deployed the token contract, an initial supply of tokens was minted to the address provided in the constructor. We can now query the `getBalance()` method on the contract to retrieve the balance of that address. Make sure to replace the `contract-address` with the deployment address you got from the previous command, and the `args` with the account you used in the constructor. -``` +```bash % aztec-cli call getBalance \ - --args 0x2337f1d5cfa6c03796db5539b0b2d5a57e9aed42665df2e0907f66820cb6eebe \ + --args $ADDRESS \ --contract-abi PrivateTokenContractAbi \ - --contract-address 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f + --contract-address $CONTRACT_ADDRESS View result: [ "{\"type\":\"bigint\",\"data\":\"1000000\"}" @@ -168,12 +195,12 @@ As you can see from the result, this address has a balance of 1000000, as expect We can now send a transaction to the network. We will transfer funds from the owner of the initial minted tokens to our other account. For this we will use the `send` command, which expects as arguments the quantity of tokens to be transferred, the sender's address, and the recipient's address. Make sure to replace all addresses in this command with the ones for your run. -``` +```bash % aztec-cli send transfer \ - --args 543 0x2337f1d5cfa6c03796db5539b0b2d5a57e9aed42665df2e0907f66820cb6eebe 0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c \ + --args 543 $ADDRESS $ADDRESS2 \ --contract-abi PrivateTokenContractAbi \ - --contract-address 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f \ - --private-key 0x2aba9e7de7075deee3e3f4ad1e47749f985f0f72543ed91063cc97a40d851f1e + --contract-address $CONTRACT_ADDRESS \ + --private-key $PRIVATE_KEY Transaction has been mined Transaction hash: 15c5a8e58d5f895c7e3017a706efbad693635e01f67345fa60a64a340d83c78c @@ -191,7 +218,7 @@ We called the `transfer` function of the contract and provided these arguments: The command output tells us the details of the transaction such as its hash and status. We can use this hash to query the receipt of the transaction at a later time: -``` +```bash % aztec-cli get-tx-receipt 15c5a8e58d5f895c7e3017a706efbad693635e01f67345fa60a64a340d83c78c Transaction receipt: @@ -207,14 +234,14 @@ Transaction receipt: Let's now call `getBalance()` on each of our accounts and we should see updated values: -``` -% aztec-cli call getBalance -a 0x2337f1d5cfa6c03796db5539b0b2d5a57e9aed42665df2e0907f66820cb6eebe -c PrivateTokenContractAbi -ca 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f +```bash +% aztec-cli call getBalance -a $ADDRESS -c PrivateTokenContractAbi -ca $CONTRACT_ADDRESS View result: [ "{\"type\":\"bigint\",\"data\":\"999457\"}" ] -% aztec-cli call getBalance -a 0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c -c PrivateTokenContractAbi -ca 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f +% aztec-cli call getBalance -a $ADDRESS2 -c PrivateTokenContractAbi -ca $CONTRACT_ADDRESS View result: [ "{\"type\":\"bigint\",\"data\":\"543\"}" From 2323ffc0bdbd45f56b9610c623343f471ae5c042 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 29 Aug 2023 17:13:13 -0400 Subject: [PATCH 4/4] update to sandbox.aztec.network --- docs/docs/dev_docs/getting_started/cli.md | 4 ++-- docs/docs/dev_docs/getting_started/sandbox.md | 4 ++-- docs/docs/dev_docs/sandbox/main.md | 4 ++-- docs/docs/external/up-quick-start.md | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/docs/dev_docs/getting_started/cli.md b/docs/docs/dev_docs/getting_started/cli.md index 50af68a62b7..abaabbe1b97 100644 --- a/docs/docs/dev_docs/getting_started/cli.md +++ b/docs/docs/dev_docs/getting_started/cli.md @@ -6,10 +6,10 @@ title: Aztec CLI The Aztec CLI is a tool designed to enable a user to interact with the Aztec Network. -## Requirements - This tutorial will use the Aztec Sandbox so you should first set it up by following [the Aztec Sandbox instructions](../sandbox/main.md). +## Requirements + You should also have [node.js](https://nodejs.org/en/download) installed with version >= 18. To install the Aztec CLI run: diff --git a/docs/docs/dev_docs/getting_started/sandbox.md b/docs/docs/dev_docs/getting_started/sandbox.md index b68f472c465..80cf2b49469 100644 --- a/docs/docs/dev_docs/getting_started/sandbox.md +++ b/docs/docs/dev_docs/getting_started/sandbox.md @@ -19,12 +19,12 @@ That's it... ## Ok, so how do I try it out? -Well, you can find instructions [at the website](https://up.aztec.network). +Well, you can find instructions [at the website](https://sandbox.aztec.network). Or you can just curl the site instead like this: ```sh -/bin/bash -c "$(curl -fsSL 'https://up.aztec.network')" +/bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')" ``` It will download and execute a script invoking docker compose with 2 containers: diff --git a/docs/docs/dev_docs/sandbox/main.md b/docs/docs/dev_docs/sandbox/main.md index 6c0e80fc14a..9ddf0ce78ac 100644 --- a/docs/docs/dev_docs/sandbox/main.md +++ b/docs/docs/dev_docs/sandbox/main.md @@ -4,7 +4,7 @@ The Aztec Sandbox is local development system against which you can build and test Noir contracts in a fast, safe, and free environment. -To learn more and to download to for yourself you can visit the [website](https://up.aztec.network). +To learn more and to download to for yourself you can visit the [website](https://sandbox.aztec.network). ## Requirements @@ -12,6 +12,6 @@ The Sandbox runs on Docker, so any x86 Docker environment should be able to host The following command will download and execute a script that uses docker compose to launch an instance of Anvil and the Sandbox side by side. This will get you up and running in just a few seconds. -`/bin/bash -c "$(curl -fsSL 'https://up.aztec.network')"` +`/bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')"` For a complete walk-through deploying and using a private contract, see our [getting started guide](../getting_started/sandbox.md). diff --git a/docs/docs/external/up-quick-start.md b/docs/docs/external/up-quick-start.md index 57e942e1c62..d6fb502788c 100644 --- a/docs/docs/external/up-quick-start.md +++ b/docs/docs/external/up-quick-start.md @@ -1,7 +1,7 @@ # Quick start -:::info -This guide is meant to be included in the up.aztec.network site and not in the main documentation. +:::info +This guide is meant to be included in the sandbox.aztec.network site and not in the main documentation. ::: To interact with the sandbox, install the [Aztec CLI](../dev_docs/cli/main.md): @@ -24,4 +24,4 @@ We can have Alice privately transfer tokens to Bob. Only Alice and Bob will know #include_code transfer yarn-project/end-to-end/src/guides/up_quick_start.sh bash noTitle,noLineNumbers,noSourceLink -To learn more, check out an extended version of this quick start [on our docs](../dev_docs/getting_started/cli.md). \ No newline at end of file +To learn more, check out an extended version of this quick start [on our docs](../dev_docs/getting_started/cli.md).