From 16a3d9cfb858527c4b59da71a457add1b7dd6d65 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 21 Sep 2023 14:30:58 +0100 Subject: [PATCH] chore(contract_deployment.md): don't require main edit (#2449) --- docs/docs/dev_docs/dapps/tutorials/contract_deployment.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md b/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md index fc940f98cf8..d677b403f77 100644 --- a/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md +++ b/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md @@ -63,7 +63,7 @@ This should have created an artifact `contracts/token/target/Token.json` with th Let's now write a script for deploying your contracts to the Sandbox. We'll create an RPC client, and then use the `ContractDeployer` class to deploy our contracts, and store the deployment address to a local JSON file. -Create a new file `src/deploy.mjs`, with a call to a `main` function that we'll populate in a second: +Create a new file `src/deploy.mjs`: ```js // src/deploy.mjs @@ -71,7 +71,7 @@ import { writeFileSync } from 'fs'; import { Contract, ContractDeployer, createAztecRpcClient, getSandboxAccountsWallets } from '@aztec/aztec.js'; import TokenContractAbi from "../contracts/token/target/Token.json" assert { type: "json" }; -async function main() {} +#include_code dapp-deploy yarn-project/end-to-end/src/sample-dapp/deploy.mjs raw main().catch((err) => { console.error(`Error in deployment script: ${err}`); @@ -79,9 +79,7 @@ main().catch((err) => { }); ``` -Now we will import the contract artifacts we have generated plus the dependencies we'll need, and then we can deploy the contracts by adding the following code to the `src/deploy.mjs` file. Here, we are using the `ContractDeployer` class with the compiled artifact to send a new deployment transaction. The `wait` method will block execution until the transaction is successfully mined, and return a receipt with the deployed contract address. - -#include_code dapp-deploy yarn-project/end-to-end/src/sample-dapp/deploy.mjs javascript +We import the contract artifacts we have generated plus the dependencies we'll need, and then we can deploy the contracts by adding the following code to the `src/deploy.mjs` file. Here, we are using the `ContractDeployer` class with the compiled artifact to send a new deployment transaction. The `wait` method will block execution until the transaction is successfully mined, and return a receipt with the deployed contract address. Note that the token's `_initialize()` method expects an `owner` address to mint an initial set of tokens to. We are using the first account from the Sandbox for this.