This is an example web app that demonstrates how to interact with an Aztec contract using the Aztec JS SDK.
- Uses the Private Voting example
- Includes an embedded wallet. This is only for demonstration purposes and not for production use.
- Works on top of the Sandbox, but can be adapted to work with a testnet.
- Install the Aztec tools from the first few steps in Quick Start Guide.
Please note that this project uses v0.86.0
version of Aztec SDK. If you wish to use a different version, please update the dependencies in the app/package.json
file to match the version of your tools.
Alternatively, you can specify v0.86.0
when updating Aztec tools by running the following commands:
aztec-up 0.86.0
aztec start --sandbox
- Compile smart contracts in
/contracts
:
(cd contracts && ./build.sh)
The build script compiles the contract and generates the artifacts.
- Deploy the contracts
Run the JS deploy script to deploy the contracts:
(cd app && yarn install)
(cd app && yarn deploy-contracts)
This will deploy the contracts and save the deployment info to app/deployed-contract.json
.
The full process involves Generating Client IVC proof
, and may take a few moments. For faster development the sandbox does not verify proofs, so this can optionally be disabled here.
Important: For a production app, you need to back up the deployment info file to a secure location as without it, you will not be able to recover the contract address.
- Run the app:
(cd app && yarn dev)
You can now interact with the deployed contract using the web app:
- Create a new account
- Like before, this will take some time to generate proofs
- Note: this will save your account keys to your browser's local storage
- Cast a vote for one of the 5 candidates
- Voting again should throw an error
- Open another browser (or an incognito window), create a new account, and cast a vote
- See the updated vote results in the first browser
The Sandbox will accept transactions without a valid proof. You can disable proof generation when working against the Sandbox as it will save time during development.
To disable proving in the deploy script, run:
PXE_PROVER=none ./deploy.sh
To disable proving in the web app, you can add the following line in app/src/embedded-wallet.ts
(uncomment the existing line):
config.proverEnabled = false;