-
Notifications
You must be signed in to change notification settings - Fork 598
feat(docs): DIP1 - Extracting how-tos #4251
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
Changes from all commits
ba43c73
0b9bb61
4928aca
5a01264
abd01da
477fa36
2c962a1
2d84e16
14bd967
b328393
a6518ea
bb8e20c
a2a46f2
335d91a
bd3a28a
642ced1
01bdf09
16dc4c4
68f8b14
4acfee4
5532126
681bd14
35bf27f
fc04a4a
f90f1a2
7f63276
25b0874
af638bd
d0d400f
d53cf69
2eb4e52
c874a46
40ecda8
d8d6103
8270625
ebefe79
574eaf8
845b913
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| title: How to Call a View Function | ||
| --- | ||
|
|
||
| This guide explains how to call a `view` function using [Aztec.js](../main.md). | ||
|
|
||
| To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#calling-an-unconstrained-view-function). | ||
|
|
||
| ```typescript | ||
| import { Contract } from "@aztec/aztec.js"; | ||
|
|
||
| const contract = await Contract.at(contractAddress, MyContractArtifact, wallet); | ||
| const balance = await contract.methods.getBalance(wallet.getAddress()).view(); | ||
| console.log(`Account balance is ${balance}`); | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| title: How to Create a New Account | ||
| --- | ||
|
|
||
| This guide explains how to create a new account using [Aztec.js](../main.md). | ||
|
|
||
| To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#creating-accounts). | ||
|
|
||
| ```typescript | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we link the reference code to source somewhere, so if the API changes the docs automatically reflect that?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| import { getSchnorrAccount } from "@aztec/aztec.js"; | ||
| import { GrumpkinPrivateKey } from "@aztec/circuit-types"; | ||
|
|
||
| const encryptionPrivateKey = GrumpkinPrivateKey.random(); | ||
| const signingPrivateKey = GrumpkinPrivateKey.random(); | ||
| const wallet = getSchnorrAccount( | ||
| pxe, | ||
| encryptionPrivateKey, | ||
| signingPrivateKey | ||
| ).waitDeploy(); | ||
| console.log(`New account deployed at ${wallet.getAddress()}`); | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| title: How to Deploy a Contract | ||
| --- | ||
|
|
||
| This guide explains how to deploy a smart contract using [Aztec.js](../main.md). | ||
|
|
||
| To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#deploying-a-token-contract). | ||
|
|
||
| ```typescript | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we link the reference code to source somewhere, so if the API changes the docs automatically reflect that? |
||
| import { Contract } from "@aztec/aztec.js"; | ||
|
|
||
| const contract = await Contract.deploy(wallet, MyContractArtifact, [ | ||
| ...constructorArgs, | ||
| ]) | ||
| .send() | ||
| .deployed(); | ||
| console.log(`Contract deployed at ${contract.address}`); | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| title: How to Send a Transaction | ||
| --- | ||
|
|
||
| This guide explains how to send a transaction using [Aztec.js](../main.md). | ||
|
|
||
| To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#sending-a-transaction). | ||
|
|
||
| ```typescript | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we link the reference code to source somewhere, so if the API changes the docs automatically reflect that? |
||
| import { Contract } from "@aztec/aztec.js"; | ||
|
|
||
| const contract = await Contract.at(contractAddress, MyContractArtifact, wallet); | ||
| const tx = await contract.methods | ||
| .transfer(amount, recipientAddress) | ||
| .send() | ||
| .wait(); | ||
| console.log( | ||
| `Transferred ${amount} to ${recipientAddress} on block ${tx.blockNumber}` | ||
| ); | ||
| ``` | ||
This file was deleted.
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update the typescript Token interface to be referencing source code instead of hard coded? |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update the hard coded snippets to reference source code instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we link the reference code to source somewhere, so if the API changes the docs automatically reflect that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i cant find it anywhere in the monorepo. only overcomplicated examples. wdyt?