Skip to content

Commit

Permalink
chore(contract_deployment.md): don't require main edit (#2449)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad authored Sep 21, 2023
1 parent 76fc2cf commit 16a3d9c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/docs/dev_docs/dapps/tutorials/contract_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,23 @@ 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
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}`);
process.exit(1);
});
```

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.

Expand Down

0 comments on commit 16a3d9c

Please sign in to comment.