Skip to content

Commit

Permalink
chore: update foundry qs qith zksync-cli usage (#61)
Browse files Browse the repository at this point in the history
Related PR: matter-labs/zksync-cli#135

- [x] Still need to make a zksync-cli release. 

# What 💻 
* Updates foundry quickstart to use zksync-cli for bootstrapping project
* Fixes linking

# Why ✋
* Quickest way to get started
* Paths had changed

# Evidence 📷
Include screenshots, screen recordings, or `console` output here
demonstrating that your changes work as intended

<!-- All sections below are optional. You can uncomment any section
applicable to your Pull Request. -->

<!-- # Notes 📝
* Any notes/thoughts that the reviewers should know prior to reviewing
the code? -->
  • Loading branch information
dutterbutter authored May 16, 2024
1 parent 897f371 commit 8985d50
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 74 deletions.
2 changes: 1 addition & 1 deletion app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const links = computed(() => {
},
{
label: 'SDK Docs',
to: 'https://zksync-sdk-docs-staging.web.app',
to: 'https://staging-sdk-docs.zksync.io/',
},
{
label: 'ZK Stack',
Expand Down
11 changes: 2 additions & 9 deletions content/00.build/10.quick-start/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,7 @@ Quickly set up `foundry-zksync` by following these steps:
cd foundry-zksync
```

2. **Prepare the Installation Script**:
Ensure the script is executable:

```bash
chmod +x ./install-foundry-zksync
```

3. **Run the Installer**:
2. **Run the Installer**:
Execute the script to install the `foundry-zksync` binaries `forge` and `cast`:

```bash
Expand Down Expand Up @@ -157,7 +150,7 @@ To deploy contracts, you'll need to securely add your wallet's private key to th
WALLET_PRIVATE_KEY=your_private_key_here
```

- Replace **`your_private_key_here`** with your actual private key. If you're using Foundry, make sure your private key starts with `0x`.
- Replace **`your_private_key_here`** with your actual private key. **If you're using Foundry, make sure your private key starts with `0x`**.
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
title: Foundry | Deploy Contract Factory
---
<!-- TODO: @dutterbutter update to simplify the project init step -->

:display-partial{path = "/_partials/_foundry_alpha_warning"}

Run the following command in your terminal to initialize the Foundry project.

```sh
git clone https://github.com/dutterbutter/zksync-foundry-quickstart-guide
cd zksync-foundry-quickstart-guide
git checkout db/deploy-contract-factory
npx zksync-cli@latest create --template qs-fs-factories foundry-contract-factory-quickstart
cd foundry-contract-factory-quickstart
```

## Set up your wallet
Expand All @@ -18,7 +19,7 @@ git checkout db/deploy-contract-factory

## Review the CrowdfundingFactory contract

The `CrowdfundingFactory.sol` we will compile and deploy is provided under the [`/src` directory](https://github.com/dutterbutter/zksync-foundry-quickstart-guide/blob/db/deploy-contract-factory/src/CrowdfundFactory.sol).
The `CrowdfundingFactory.sol` we will compile and deploy is provided under the [`/src` directory](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/foundry/factory/src/CrowdfundFactory.sol).

The `CrowdfundingFactory.sol`contract will be used to deploy multiple instances of
the `CrowdfundingCampaign.sol` contract from the previous guide.
Expand Down Expand Up @@ -75,7 +76,7 @@ For this particular guide we are making use of `zksolc`.
To compile the contracts in the project, run the following command:

```bash
forge build --zksync
forge build --zksync --use 0.8.20
```

Upon successful compilation, you'll receive output detailing the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Hardhat | Deploy Contract Factory
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-factories contract-factory-quickstart
npx zksync-cli@latest create --template qs-factories contract-factory-quickstart
cd contract-factory-quickstart
```

Expand All @@ -17,7 +17,7 @@ cd contract-factory-quickstart
## Compile the contracts

This section will focus on compiling and deploying the `CrowdfundingFactory.sol`
contract that is provided under the [`/contracts` directory](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/factories/contracts/CrowdfundFactory.sol).
contract that is provided under the [`/contracts` directory](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/factory/contracts/CrowdfundFactory.sol).

The `CrowdfundingFactory.sol`contract will be used to deploy multiple instances of
the `CrowdfundingCampaign.sol` contract from the previous guide.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
title: Foundry | Deploy Contract
---

:display-partial{path = "/_partials/_environment-setup-with-foundry"}
:display-partial{path = "/_partials/_foundry_alpha_warning"}

Run the following command in your terminal to initialize the Foundry project.

```sh
npx zksync-cli@latest create --template qs-fs-hello-zksync hello-zksync-foundry-quickstart
cd hello-zksync-foundry-quickstart
```

## Set up your wallet

Expand All @@ -13,7 +20,7 @@ title: Foundry | Deploy Contract
This guide
introduces a crowdfunding campaign contract aimed at supporting Zeek's inventive ventures.

Let's start by reviewing the starter contract in the [`src/` directory](https://github.com/dutterbutter/zksync-foundry-quickstart-guide/blob/main/src/Crowdfund.sol).
Let's start by reviewing the starter contract in the [`src/` directory](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/foundry/hello-zksync/src/Crowdfund.sol).

::drop-panel
::panel{label="CrowdfundingCampaign.sol"}
Expand Down Expand Up @@ -103,7 +110,7 @@ located in the `/out` folder.

### Deploy the CrowdfundingCampaign contract

The deployment script is located at [`/script/Deploy.s.sol`](https://github.com/dutterbutter/zksync-foundry-quickstart-guide/blob/main/script/Deploy.s.sol).
The deployment script is located at [`/script/Deploy.s.sol`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/foundry/hello-zksync/script/Deploy.s.sol).

```solidity
// SPDX-License-Identifier: UNLICENSED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Hardhat | Deploy Contract
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-hello-zksync hello-zksync-quickstart
npx zksync-cli@latest create --template qs-hello-zksync hello-zksync-quickstart
cd hello-zksync-quickstart
```

Expand All @@ -16,7 +16,7 @@ cd hello-zksync-quickstart
## Compile the CrowdfundingCampaign.sol contract

This guide introduces a crowdfunding campaign contract aimed at supporting Zeek's inventive ventures.
Let's start by reviewing the starter contract in the [`contracts/` directory](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hello-zksync/contracts/Crowdfund.sol).
Let's start by reviewing the starter contract in the [`contracts/` directory](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/hello-zksync/contracts/Crowdfund.sol).

::drop-panel
::panel{label="CrowdfundingCampaign.sol"}
Expand Down Expand Up @@ -96,7 +96,7 @@ The compiled artifacts will be located in the `/artifacts-zk` folder.

## Deploy the contract

The deployment script is located at [`/deploy/deploy.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hello-zksync/deploy/deploy.ts).
The deployment script is located at [`/deploy/deploy.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/hello-zksync/deploy/deploy.ts).

```typescript
import { deployContract } from "./utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Learn to deploy contract factories in the ZKsync environment.
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-paymaster contract-paymaster-quickstart
npx zksync-cli@latest create --template qs-paymaster contract-paymaster-quickstart
cd contract-paymaster-quickstart
```

Expand Down Expand Up @@ -166,7 +166,7 @@ Successfully compiled 1 Solidity file

The compiled artifacts will be located in the `/artifacts-zk` folder.

The script to deploy the `ApprovalFlowPaymaster` contract is located at `/deploy/deployApprovalFlowPaymaster.ts`.
The script to deploy the `ApprovalFlowPaymaster` contract is located at [`/deploy/deployApprovalFlowPaymaster.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/paymaster/deploy/deployApprovalFlowPaymaster.ts).

```typescript
import { deployContract, getWallet, getProvider } from "./utils";
Expand Down Expand Up @@ -263,8 +263,9 @@ Paymaster ETH balance is now 5000000000000000

## Interact with the `ApprovalFlowPaymaster` contract

This section will navigate you through the steps to interact with the `ApprovalFlowPaymaster` contract,
using it to cover transaction fees for your operation.
This section will navigate you through the steps to interact with the
[`ApprovalFlowPaymaster`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/paymaster/contracts/ApprovalFlowPaymaster.sol)
contract, using it to cover transaction fees for your operation.

### Obtain CROWN tokens

Expand All @@ -287,7 +288,7 @@ Ensure that your wallet is connected and configured for the Sepolia network befo

### Interaction script

The interaction script is situated in the `/deploy/interact/` directory, named `interactWithApprovalFlowPaymaster.ts`.
The interaction script is situated in the `/deploy/interact/` directory, named [`interactWithApprovalFlowPaymaster.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/paymaster/deploy/interact/interactWithApprovalFlowPaymaster.ts).

Ensure the `CONTRACT_ADDRESS` and `PAYMASTER_ADDRESS` variables are set to your deployed contract and paymaster addresses, respectively.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Learn to deploy contract factories in the ZKsync environment.
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-paymaster contract-paymaster-quickstart
npx zksync-cli@latest create --template qs-paymaster contract-paymaster-quickstart
cd contract-paymaster-quickstart
```

Expand All @@ -18,7 +18,8 @@ cd contract-paymaster-quickstart

## Understanding the `GeneralPaymaster` contract

Let's start by reviewing the `GeneralPaymaster.sol` contract in the `contracts/` directory:
Let's start by reviewing the [`GeneralPaymaster.sol`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/paymaster/contracts/GaslessPaymaster.sol)
contract in the `contracts/` directory:

::drop-panel
::panel{label="GeneralPaymaster.sol"}
Expand Down Expand Up @@ -136,7 +137,7 @@ Successfully compiled 4 Solidity file

The compiled artifacts will be located in the `/artifacts-zk` folder.

The script to deploy the `GaslessPaymaster` is located at `/deploy/deployGaslessPaymaster.ts`.
The script to deploy the `GaslessPaymaster` is located at [`/deploy/deployGaslessPaymaster.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/paymaster/deploy/deployGaslessPaymaster.ts).

```typescript
import { deployContract, getWallet, getProvider } from "./utils";
Expand Down Expand Up @@ -234,7 +235,7 @@ Paymaster ETH balance is now 5000000000000000
This section will navigate you through the steps to interact with the `GeneralPaymaster` contract,
using it to cover transaction fees for your operation.

The interaction script is situated in the `/deploy/interact/` directory, named `interactWithGaslessPaymaster.ts`.
The interaction script is situated in the `/deploy/interact/` directory, named [`interactWithGaslessPaymaster.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/paymaster/deploy/interact/interactWithGaslessPaymaster.ts).

Ensure the `CONTRACT_ADDRESS` and `PAYMASTER_ADDRESS` variables are set to your deployed contract and paymaster addresses, respectively.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: Hardhat | Contract Testing
title: Foundry | Contract Testing
---

<!-- TODO: @dutterbutter update to simplify the project init step -->
:display-partial{path = "/_partials/_foundry_alpha_warning"}

Run the following command in your terminal to initialize the Foundry project.

```sh
git clone https://github.com/dutterbutter/zksync-foundry-quickstart-guide
cd zksync-foundry-quickstart-guide
git checkout db/contract-testing
npx zksync-cli@latest create --template qs-fs-testing foundry-contract-testing-quickstart
cd foundry-contract-testing-quickstart
```

---
Expand Down Expand Up @@ -91,7 +91,7 @@ For this particular guide we are making use of `zksolc`.
To compile the contracts in the project, run the following command:

```bash
forge build --zksync
forge build --zksync --use 0.8.20
```

Upon successful compilation, you'll receive output detailing the
Expand All @@ -114,7 +114,7 @@ located in the `/out` folder.
This section describes the testing `CrowdfundingCampaign.sol` contract. Let's
start by reviewing the tests for `CrowdfundingCampaign.sol` contract provided
during the initialization step in the `/test` directory, specifically the
[`CrowdfundingCampaign.t.sol` file](https://github.com/dutterbutter/zksync-foundry-quickstart-guide/blob/db/contract-testing/test/CrowdfundingCampaign.t.sol).
[`CrowdfundingCampaign.t.sol` file](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/foundry/testing/test/CrowdfundingCampaign.t.sol).

```solidity
// SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Hardhat | Contract Testing
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-testing contract-testing-quickstart
npx zksync-cli@latest create --template qs-testing contract-testing-quickstart
cd contract-testing-quickstart
```

Expand Down Expand Up @@ -145,7 +145,7 @@ The compiled artifacts will be located in the `/artifacts-zk` folder.
This section describes testing the `CrowdfundingCampaign.sol` contract. Let's
start by reviewing the tests for `CrowdfundingCampaign.sol` contract provided
during the initialization step in the `/tests` directory, specifically the
[`crowdFunding.test.ts` file](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/testing/test/crowdFunding.test.ts).
[`crowdFunding.test.ts` file](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/testing/test/crowdFunding.test.ts).

```typescript
import { expect } from "chai";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Hardhat | Contract Upgrading
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-upgrade contract-upgrade-quickstart
npx zksync-cli@latest create --template qs-upgrade contract-upgrade-quickstart
cd contract-upgrade-quickstart
```

Expand All @@ -22,7 +22,7 @@ transitioning to a proxy pattern. This approach separates the
contract's logic (which can be upgraded) from its persistent state
(stored in the proxy).

In the `contracts/` directory you'll observe the refactored the [`CrowdfundingCampaign` contract](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/contracts/CrowdfundingCampaign.sol)
In the `contracts/` directory you'll observe the refactored the [`CrowdfundingCampaign` contract](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/contracts/CrowdfundingCampaign.sol)
which initializes state variables through an
`initialize` function instead of the constructor, in line with the proxy pattern.

Expand Down Expand Up @@ -121,7 +121,7 @@ The compiled artifacts will be located in the `/artifacts-zk` folder.

## Deploy the beacon and contract

You'll find the necessary deployment script at [`/deploy/deployBeaconProxy.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/deploy/deployBeaconProxy.ts).
You'll find the necessary deployment script at [`/deploy/deployBeaconProxy.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/deploy/deployBeaconProxy.ts).

```typescript
import { getWallet } from "./utils";
Expand Down Expand Up @@ -229,7 +229,7 @@ this constraint, ensuring contributions are made within the allowed period.

**Enhanced Contract:**

The upgraded contract, [`CrowdfundingCampaignV2.sol`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/contracts/CrowdfundingCampaignV2.sol),
The upgraded contract, [`CrowdfundingCampaignV2.sol`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/contracts/CrowdfundingCampaignV2.sol),
located in the `/contracts` directory,
incorporates these changes:

Expand Down Expand Up @@ -278,7 +278,7 @@ The compiled artifacts will be located in the `/artifacts-zk` folder.
## Upgrade to `CrowdfundingCampaignV2`

This section describes the upgrade process to `CrowdfundingCampaignV2.sol` contract. Let's
start by reviewing the [`upgradeBeaconCrowdfundingCampaign.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/deploy/upgrade-scripts/upgradeBeaconCrowdfundingCampaign.ts)
start by reviewing the [`upgradeBeaconCrowdfundingCampaign.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/deploy/upgrade-scripts/upgradeBeaconCrowdfundingCampaign.ts)
script in the `deploy/upgrade-scripts` directory:

Make sure to replace `YOUR_BEACON_ADDRESS_HERE` with the address of your deployed beacon and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Hardhat | Contract Upgrading
Run the following command in your terminal to initialize the project.

```sh
npx zksync-cli create --template qs-upgrade contract-upgrade-quickstart
npx zksync-cli@latest create --template qs-upgrade contract-upgrade-quickstart
cd contract-upgrade-quickstart
```

Expand All @@ -25,7 +25,7 @@ contract's logic (which can be upgraded) from its persistent state

### Refactoring for Proxy Compatibility

In the `contracts/` directory you'll observe the refactored the [`CrowdfundingCampaign` contract](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/contracts/CrowdfundingCampaign.sol)
In the `contracts/` directory you'll observe the refactored the [`CrowdfundingCampaign` contract](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/contracts/CrowdfundingCampaign.sol)
which initializes state variables through an
`initialize` function instead of the constructor, in line with the
Transparent Proxy pattern.
Expand Down Expand Up @@ -123,7 +123,7 @@ Successfully compiled 3 Solidity file

The compiled artifacts will be located in the `/artifacts-zk` folder.

The deployment script is located at [`/deploy/deployTransparentProxy.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/deploy/deployTransparentProxy.ts).
The deployment script is located at [`/deploy/deployTransparentProxy.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/deploy/deployTransparentProxy.ts).

```typescript
import { getWallet } from "./utils";
Expand Down Expand Up @@ -222,7 +222,7 @@ this constraint, ensuring contributions are made within the allowed period.

**Enhanced Contract:**

The upgraded contract, [`CrowdfundingCampaignV2.sol`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/contracts/CrowdfundingCampaignV2.sol),
The upgraded contract, [`CrowdfundingCampaignV2.sol`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/contracts/CrowdfundingCampaignV2.sol),
located in the `/contracts` directory, incorporates these changes:

- **Deadline Variable:** A new state variable deadline defines the campaign's end time,
Expand Down Expand Up @@ -273,7 +273,7 @@ The compiled artifacts will be located in the `/artifacts-zk` folder.

This section guides you through upgrading the `CrowdfundingCampaign` contract
to its second version, `CrowdfundingCampaignV2`.
Review the [`upgradeCrowdfundingCampaign.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/upgradability/deploy/upgrade-scripts/upgradeCrowdfundingCampaign.ts)
Review the [`upgradeCrowdfundingCampaign.ts`](https://github.com/matter-labs/zksync-contract-templates/blob/main/templates/quickstart/hardhat/upgradability/deploy/upgrade-scripts/upgradeCrowdfundingCampaign.ts)
script located within the `deploy/upgrade-scripts` directory to begin.

Replace `YOUR_PROXY_ADDRESS_HERE` with the actual address of your
Expand Down
Loading

0 comments on commit 8985d50

Please sign in to comment.