-
Notifications
You must be signed in to change notification settings - Fork 613
docs(feat): Aztec js intro page #11804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5028d30
aztecjs intro page
catmcgee b28959a
docs comments
catmcgee e214e67
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee 4c66971
removed duplicate deploy guide
catmcgee 7ff34ba
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee 3713bd1
Apply suggestions from code review
catmcgee ecac744
joshs suggestions
catmcgee fa4c3a4
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee 026a2a3
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee eed38bd
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee 44d633c
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee b2e316b
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee 5561023
fix build error
catmcgee ca19574
Merge branch 'master' into docs/aztecjs-intro-page
catmcgee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,26 +1,68 @@ | ||
| --- | ||
| title: How to Deploy a Contract | ||
| tags: [contracts] | ||
| sidebar_position: 1 | ||
| --- | ||
|
|
||
| This guide explains how to deploy a smart contract using Aztec.js. | ||
| Once you have [compiled](../smart_contracts/how_to_compile_contract.md) your contracts you can proceed to deploying them using Aztec.js. | ||
|
|
||
| You can use this method to deploy your contracts to the sandbox or to a remote network. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| You should have a wallet to act as the deployer, and a contract artifact ready to be deployed. | ||
| - Contract artifacts ready (go to [How to Compile Contract](../smart_contracts/how_to_compile_contract.md) for instructions on how to compile contracts) | ||
| - Aztec Sandbox running (go to [Getting Started](../../getting_started.md) for instructions on how to install and run the sandbox) | ||
|
|
||
| ## Deploy | ||
|
|
||
| Contracts can be deployed using the `aztec.js` library. | ||
|
|
||
| Compile the contract: | ||
|
|
||
| ```bash | ||
| aztec-nargo compile | ||
| ``` | ||
|
|
||
| Generate the typescript class: | ||
|
|
||
| ```bash | ||
| aztec codegen ./aztec-nargo/output/target/path -o src/artifacts | ||
| ``` | ||
|
|
||
| This would create a typescript file like `Example.ts` in `./src/artifacts`. | ||
|
|
||
| You can use the `Contract` class to deploy a contract: | ||
|
|
||
| #include_code dapp-deploy yarn-project/end-to-end/src/sample-dapp/deploy.mjs typescript | ||
|
|
||
| Or you can use the generated contract class. See [below](#deploying-token-contract) for more details. | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Deploy Arguments | ||
|
|
||
| There are several optional arguments that can be passed: | ||
|
|
||
| The `deploy(...)` method is generated automatically with the typescript class representing your contract. | ||
|
|
||
| Additionally the `.send()` method can have a few optional arguments too, which are specified in an optional object: | ||
|
|
||
| You can learn how to create wallets from [this guide](./create_account.md). | ||
| #include_code deploy_options yarn-project/aztec.js/src/contract/deploy_method.ts typescript | ||
|
|
||
| You can read about contract artifacts [here](../../../aztec/smart_contracts/contract_structure.md). | ||
| ### Deploying token contract | ||
|
|
||
| ## Import the contract artifact | ||
| To give you a more complete example we will deploy a `Token` contract whose artifacts are included in the `@aztec/noir-contracts.js` package. | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
|
|
||
| In this guide we are using a Token contract artifact. | ||
| ```ts | ||
| #include_code create_account_imports yarn-project/end-to-end/src/composed/docs_examples.test.ts raw | ||
| #include_code import_contract yarn-project/end-to-end/src/composed/docs_examples.test.ts raw | ||
| #include_code import_token_contract yarn-project/end-to-end/src/composed/docs_examples.test.ts raw | ||
|
|
||
| #include_code import_token_contract yarn-project/end-to-end/src/composed/docs_examples.test.ts typescript | ||
| async function main(){ | ||
|
|
||
| ## Deploy contract | ||
| #include_code full_deploy yarn-project/end-to-end/src/composed/docs_examples.test.ts raw | ||
|
|
||
| #include_code deploy_contract yarn-project/end-to-end/src/composed/docs_examples.test.ts typescript | ||
| } | ||
| ``` | ||
|
|
||
| To learn how to send a transaction from Aztec.js read [this guide](./send_transaction.md). You can also call a `view` function from Aztec.js by reading [this guide](./call_view_function.md). | ||
| :::note | ||
| You can try running the deployment with the same salt the second time in which case the transaction will fail because the address has been already deployed to. | ||
| ::: | ||
This file contains hidden or 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,29 @@ | ||
| --- | ||
| title: Aztec.js | ||
| tags: [aztec.js, javascript, typescript] | ||
| --- | ||
|
|
||
| import DocCardList from "@theme/DocCardList"; | ||
|
|
||
| Aztec.js is a library that provides APIs for managing accounts and interacting with contracts on the Aztec network. It communicates with the [Private eXecution Environment (PXE)](../../../aztec/concepts/pxe/index.md) through a `PXE` implementation, allowing developers to easily register new accounts, deploy contracts, view functions, and send transactions. | ||
|
|
||
| ## Installing | ||
|
|
||
| ``` | ||
| npm install @aztec/aztec.js | ||
| ``` | ||
|
|
||
| ## Importing | ||
|
|
||
| At the top of your JavaScript file, you can import what you need, eg: | ||
|
|
||
| #include_code import_aztecjs yarn-project/end-to-end/src/e2e_simple.test.ts typescript | ||
|
|
||
| ## Flow | ||
|
|
||
| These are some of the important functions you'll need to use in your Aztec.js: | ||
|
|
||
| - [Create an account with `@aztec/accounts`](./create_account.md) | ||
| - [Deploy a contract](./deploy_contract.md) | ||
| - [Simulate a function call](./call_view_function.md) | ||
| - [Sign a transaction](./send_transaction.md) | ||
|
catmcgee marked this conversation as resolved.
Outdated
|
||
This file contains hidden or 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
69 changes: 0 additions & 69 deletions
69
docs/docs/developers/guides/smart_contracts/how_to_deploy_contract.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.