-
Notifications
You must be signed in to change notification settings - Fork 298
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
Docs for sandbox usage #1477
Docs for sandbox usage #1477
Conversation
…ages into pw/sandbox-docs
…ages into pw/sandbox-docs
…ages into pw/sandbox-docs
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.
LGTM! I left a bunch of suggestions, but nothing that would go against merging the PR.
docs/docs/dev_docs/sandbox/main.md
Outdated
That's it! We have successfully deployed a private token contract to an instance of the Aztec network and mined private state-transitioning transactions. We have also queried the resulting state all via the interfaces provided by the contract. | ||
|
||
## Accounts and Keys |
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.
This section feels a bit out of place. Maybe it makes sense to run the whole flow with just one wallet, so we can showcase the addPublicKeyAndPartialAddress
usage as part of it, rather than explaining it separately in this section? We'll lose the ability to query Bob's balance, but I think that's not too bad. It will also make the account setup code a lot easier to follow, since we can remove the loops, Promise.all, etc.
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 kind of felt the same about that section. The reason I used 2 accounts is that without it you can't see the results of the transfer, i.e. Bob's balance.
It's a compromise really. In a private transaction you can only see one side of it but that doesn't make a very good demo!
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.
but that doesn't make a very good demo
I disagree - I think it's a great demo for a private-first chain! Otherwise this demo is exactly the same as a regular public ERC20. The twist where you cannot see what happened in the recipient's account is important IMO.
const tokenContractTx = PrivateTokenContract.deploy( | ||
aztecRpc, | ||
initialSupply, // the initial supply | ||
alice // the owner of the initial supply | ||
).send(); |
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.
If you pass in the wallet instead of the aztecRpc, you can call deployed()
to get the instance. Note that this only makes sense if we adapt this flow to go with a single wallet.
const viewUnencryptedLogs = async () => { | ||
const lastBlock = await aztecRpc.getBlockNum(); | ||
logger(`Retrieving unencrypted logs for block ${lastBlock}`); | ||
const logs = await aztecRpc.getUnencryptedLogs(lastBlock, 1); | ||
const unrolledLogs = L2BlockL2Logs.unrollLogs(logs); | ||
const asciiLogs = unrolledLogs.map((log) => log.toString("ascii")); | ||
logger(`Emitted logs: `, asciiLogs); | ||
}; |
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.
Feels like this should be moved to an util within aztec.js. Not for this PR, of course.
logger( | ||
`Alice's balance ${await tokenContractAlice.methods | ||
.getBalance(alice) | ||
.view()}` | ||
); | ||
// Check Bob's balance | ||
logger( | ||
`Bob's balance ${await tokenContractBob.methods.getBalance(bob).view()}` | ||
); |
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.
You don't really need to use the different tokenContractAlice/tokenContractBob for checking the different balances, since the RPC has access to the encrypted notes of both.
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.
That's right, I just thought it read a bit better that Alice checks her balance with her instance and Bob checks his with his.
const transferTx = tokenContractAlice.methods | ||
.transfer(transferQuantity, alice, bob) | ||
.send(); | ||
// Now send the transaction to the network and wait for it to settle | ||
await transferTx.wait(); |
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.
const transferTx = tokenContractAlice.methods | |
.transfer(transferQuantity, alice, bob) | |
.send(); | |
// Now send the transaction to the network and wait for it to settle | |
await transferTx.wait(); | |
await tokenContractAlice.methods | |
.transfer(transferQuantity, alice, bob) | |
.send() | |
.wait(); |
WDYT? Feels more succinct, but it's a matter of personal style.
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 am a fan of concise syntax when it doesn't worsen readability and it's very readable here so I would go with the change.
Co-authored-by: Santiago Palladino <[email protected]>
…ages into pw/sandbox-docs
Some docs for sandbox retrieval/usage.
Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.