Skip to content

Commit

Permalink
chore: edit quick-start contents
Browse files Browse the repository at this point in the history
  • Loading branch information
itsacoyote committed Apr 12, 2024
1 parent 6f863e9 commit 0326651
Show file tree
Hide file tree
Showing 26 changed files with 534 additions and 755 deletions.
Binary file modified bun.lockb
Binary file not shown.
140 changes: 140 additions & 0 deletions content/10.quick-start/00.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
title: Getting Started
description: Learn to build and deploy smart contracts on zkSync Era.
---

Welcome to the Quickstart Guide for deploying smart contracts on zkSync!
In this guide, we'll walk you through the process of creating and deploying a simple smart contract that creates a crowdfunding campaign for Zeek.

By the end of the series, you will learn integral pieces that will
help you become a great developer on zkSync! You will learn how to:

:check-icon Initialize a new project with zksync-cli

:check-icon Deploy contracts on zkSync Era using Hardhat or Foundry.

:check-icon Test your contracts with Hardhat or Foundry.

:check-icon Implement upgradable patterns for your contracts.

:check-icon Implement a Paymaster to simplify transactions for your users.

## Install zksync-cli

Our Quickstart Guide series utilizes the `zksync-cli` to help you develop and interact with zkSync from your local machine.
<!-- TODO: update link -->
<!-- Check out our [zksync-cli section](/content/tooling/zksync-cli) to learn more on how to use the CLI. -->

You will need to install a couple tools to effectively use `zksync-cli`:

#### Install Node.js or Bun.sh

You will need either Node.js or Bun.sh.
The choice depends on your project's requirements and personal preference for package management and execution speed.
If you are unfamiliar with both, choose Node.js.

- Node.js
- Download the Long-Term Support (LTS) version from the :external-link{text="official Node.js website" href="https://nodejs.org/en/download"}.
- For first-time users, the :external-link{text="Node.js usage guide" href="https://nodejs.org/api/synopsis.html#usage"}
offers comprehensive instructions on getting started.
- Bun.sh
- Obtain the latest version from the :external-link{text="Bun installation page" href="https://bun.sh/docs/installation"}.
Bun.sh is known for its high performance and modern JavaScript features.

### Setup era local node (optional)

Our Quick Start series will have you compile and deploy contracts to
zkSync Sepolia testnet which requires you to have ETH in your wallet for funding transactions.
Our `zksync-cli` tool provides a way for you to setup a test node locally.
This era local node allows for quicker testing and debugging processes without incurring testnet transaction costs.

#### Install Docker

The era local node will need Docker to run locally on your machine.
Download the appropriate version from the :external-link{text="Docker website" href="https://docs.docker.com/engine/install/"}.

#### Run a local zkSync Era node

Run the following command in your terminal:

```bash
zksync-cli dev start
```

Choose "In memory node" to deploy a local zkSync Era node in a Docker container.

The local era node will also include pre-configured rich wallets for use,
<!-- TODO: update link -->
<!-- visit [era-test-node rich wallets](https://era.zksync.io/docs/tools/testing/era-test-node.html#use-pre-configured-rich-wallets) -->

Your local zkSync Era node is accessible at **[http://127.0.0.1:8011](http://127.0.0.1:8011/)**, ready for deployment or testing purposes.

## Choose Hardhat or Foundry

Our Quickstart series provides two options for your learning process using
either Hardhat or Foundry. Pick one to use and stick with as you go through
each of the guides.

<!-- Create a component that sets which tool they use and pre-set the tabs -->

### Install foundry-zksync

If you choose to use Foundry for the Quick Start series, you will need to
install the `foundry-zksync` tool. This tool is a specialized fork of Foundry, tailored for zkSync.
It extends Foundry's capabilities for Ethereum app development to support zkSync,
allowing for the compilation, deployment, testing, and interaction with smart contracts on zkSync.

::callout{icon="i-heroicons-information-circle-16-solid" color="amber"}
`foundry-zksync` is still in an alpha stage, so some features might not be fully supported
yet and may not work as fully intended. It is open-sourced and contributions are welcome.
::

Install `foundry-zksync` with the following command:
<!-- TODO: @dutterbutter this should be a single curl command -->
```bash
curl -L https://foundry-zksync.zksync.io | bash
```

## Fund your wallet

If you did not set up a local era node for development and plan to use zkSync Sepolia testnet, you will need testnet ETH to fund transactions.

1. Obtaining Testnet ETH:

- Use the [LearnWeb3 faucet](https://learnweb3.io/faucets/zksync_sepolia/)
to directly receive testnet ETH on zkSync Sepolia.
- Alternatively, acquire SepoliaETH from [recommended faucets](https://www.notion.so/tooling/network-faucets.md) and
transfer it to the zkSync Sepolia testnet via the [zkSync bridge](https://portal.zksync.io/bridge/?network=sepolia).

1. Verify your balance:

- Check your wallet's balance using the [zkSync Sepolia explorer](https://sepolia.explorer.zksync.io/).

## Configure your wallet in a project

To deploy contracts, you'll need to securely add your wallet's private key to the project environment. Follow these steps when you set up a new project:

1. **Extract Your Private Key:**
<!-- markdownlint-disable-next-line MD013 -->
- If you are using the local era node, use a private key from the available rich accounts. Otherwise, find your personal wallet's private key. For MetaMask users, here's how to :external-link{ text="export your wallet's private key" href="https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key" }.

1. **Prepare the Environment File:**
- Locate the **`.env-example`** file in your project directory.
- Rename this file to **`.env`**.

1. **Add Your Private Key:**
- Open the `.env` file and add your private key in the following format:

```sh
WALLET_PRIVATE_KEY=your_private_key_here
```

- Replace **`your_private_key_here`** with your actual private key.

## Next Steps

You should now have a fully working local environment to build new projects on zkSync!

- Continue to [Hello zkSync!](/quick-start/hello-zksync) to begin the series on building a crowdfunding campaign for Zeek.
<!-- TODO: add a link to other guides -->
- You can skip on to creating your own projects using `zksync-cli` with your fully set up local dev environment.
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,45 @@ title: Hello zkSync!
description: Learn to deploy smart contracts efficiently in the zkSync environment.
---

Welcome to the Quickstart Guide for deploying smart contracts on zkSync! In this guide, we'll walk you through the process
of creating and deploying a simple smart contract that creates a crowdfunding campaign for Zeek.
Welcome to the Quickstart Guide for deploying smart contracts on zkSync! In this series, we'll walk you through the process
of creating and deploying a simple smart contract that creates a crowdfunding campaign for Zeek. In this section you will learn the following:

:check-icon Initializing a new project with zkSync-cli.
:check-icon Initialize a new project with zkSync-cli.

:check-icon Crafting a smart contract to fund Zeek's latest adventure.
:check-icon Craft a smart contract to fund Zeek's latest adventure.

:check-icon Deploying the contract on the zkSync Era using your choice of Hardhat or Foundry.
:check-icon Deploy the contract on the zkSync Era using your choice of Hardhat or Foundry.

Let's dive in and start your developer journey on zkSync!

## Framework selection

Select the framework you want to get started using zkSync Era with.

::content-switcher
---
items: [{
label: 'Hardhat',
partial: '_index/_hardhat_deploy_contract'
partial: '_hello-zksync/_hardhat_deploy_contract'
}, {
label: 'Foundry',
partial: '_index/_foundry_deploy_contract'
partial: '_hello-zksync/_foundry_deploy_contract'
}]
---
::

## Takeaways

- **EVM Compatibility:** zkSync is EVM compatible and you can write smart contracts in Solidity or Vyper.
- **Development Tools:** zkSync supports your favorite development toolkit Hardhat and Foundry.
- **Custom Compilation:** Contracts deployed to zkSync are compiled using `zksolc` or `zkvyper` as
they generate a special bytecode for zkSync's ZKEVM.
- **Development Tools:** zkSync supports your favorite development toolkit Hardhat and Foundry.

## Next steps

Having successfully deployed your first contract on zkSync, you're well on your way to becoming
a proficient zkSync developer. To expand your expertise:

- **Explore Contract Factories:** Enhance your project by building a contract factory
for the `CrowdfundingCampaign` contract in the next guide. This will allow you to efficiently
for the `CrowdfundingCampaign` contract in the [next guide](/quick-start/deploy-factory). This will allow you to efficiently
manage multiple crowdfunding campaigns, each with its own unique parameters.
- **Dive Deeper into zkSync Features:** Investigate advanced zkSync features such as account abstraction,
and paymasters.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
title: Contract Factories
description: Learn how to deploy and manage crowdfunding smart contracts on zkSync using contract factories.
description: Learn how to deploy and manage multiple smart contracts on zkSync using contract factories.
---

This second quickstart installment advances from your introductory exploration of smart contract deployment to dive into the utility of contract factories.
Through this guide, you'll learn how to streamline the deployment of multiple crowdfunding campaigns using a single contract factory, leveraging the
foundational `CrowdfundingCampaign` contract in the first guide.

:check-icon Advancing your zkSync development journey with contract factories.
:check-icon Advance your zkSync development journey with contract factories.

:check-icon Constructing a contract factory to create multiple crowdfunding campaigns.
:check-icon Construct a contract factory to create multiple crowdfunding campaigns.

:check-icon Seamlessly deploying your contract factory on zkSync Era, using either Hardhat or Foundry.
:check-icon Seamlessly deploy your contract factory on zkSync Era, using either Hardhat or Foundry.

Let's explore the efficiency and scalability that contract factories bring.

### What is a contract factory?
## What is a contract factory?

A contract factory is a design pattern that allows for the creation of multiple
contract instances from a single "factory" contract. It's essentially a contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ of testing. This guide will walk you through the steps to ensure your `Crowdfund
contracts, introduced in our first guide and efficiently deployed through contract factories
in the second, work flawlessly.

:check-icon Elevating your zkSync toolkit with robust contract testing techniques.
:check-icon Elevate your zkSync toolkit with robust contract testing techniques.

:check-icon Crafting comprehensive tests for your `CrowdfundingCampaign` to ensure reliability and security.
:check-icon Craft comprehensive tests for your `CrowdfundingCampaign` to ensure reliability and security.

:check-icon Using Hardhat or Foundry to write and run tests, ensuring your campaigns are ready.
:check-icon Use Hardhat or Foundry to write and run tests, ensuring your campaigns are ready.

Dive into the world of smart contract testing and solidify the foundation of your zkSync projects.

## Framework selection

Select the framework you want to get started using zkSync Era with.
## Setup the project

::content-switcher
---
Expand Down Expand Up @@ -49,7 +47,7 @@ that enhance the testing process.
With a solid foundation in contract testing, you're well-equipped to advance your zkSync
development journey. Consider the following steps to further your expertise:

- **Upgradeability**: Delve into the next guide focusing on contract upgradability.
- **Upgradeability**: Delve into the [next guide](/quick-start/upgrading) focusing on contract upgradability.
Learning to make your contracts upgradeable will enable you to update and improve your smart contracts
over time without losing state or funds.
- **Advanced zkSync Integrations:** Explore deeper into zkSync's ecosystem by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ title: Upgradability
description: Learn to make smart contracts upgradeable within the zkSync ecosystem.
---

Welcome back to our Quickstart Series, the express lane to zkSync development!
In this fourth installment, we embark on a journey through contract upgradability,
an important aspect for maintaining and enhancing smart contracts over time. This guide will
lead you through the strategies and practices for making the `CrowdfundingCampaign` contract,
introduced in the first guide and brought to life in subsequent guides, **upgradeable**.
lead you through the strategies and practices for making the `CrowdfundingCampaign` contract, **upgradeable**.

:check-icon Harnessing advanced techniques for contract upgradability in zkSync.
:check-icon Harness advanced techniques for contract upgradability in zkSync.

:check-icon Implementing upgradeable patterns for the `CrowdfundingCampaign` to ensure long-term adaptability and improvement.
:check-icon Implement upgradeable patterns for the `CrowdfundingCampaign` to ensure long-term adaptability and improvement.

:check-icon Leveraging tools and best practices in zkSync to facilitate seamless contract upgrades.
:check-icon Leverage tools and best practices in zkSync to facilitate seamless contract upgrades.

Begin to understand smart contract evolution and empower your zkSync applications with the
flexibility of upgradability.

### Select preferred upgrade mechanism
Select your preferred upgrade mechanism:

::content-switcher
---
Expand Down Expand Up @@ -50,7 +48,7 @@ functionalities evolve. This approach provides a resilient framework for your dA

### Next Steps

- **Exploring Paymasters:** Dive into the next guide focused on using paymasters
- **Exploring Paymasters:** Continue on to the next guide focused on [using paymasters](/quick-start/paymaster)
with your smart contracts. Paymasters abstract gas payments in transactions,
offering new models for transaction fee management and enhancing user experience in dApps.
- **Advanced zkSync Integrations:** Explore deeper into zkSync's ecosystem by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
---
title: Paymaster
description: Learn how to write and customize your documentation.
description: Implement a paymaster flow into your project.
---

WWelcome back to our Quickstart Series on mastering zkSync development! In this guide, we move beyond the basics
Welcome to the final part of our Quickstart Series on mastering zkSync development!
In this guide, we move beyond the basics
of smart contract deployment and the creation of contract factories to explore the innovative concept of paymasters
in the zkSync ecosystem. This guide will illuminate the power of paymasters to revolutionize transaction
fee management and enhance user experiences within your dApps.

:check-icon Delving deeper into zkSync development with the introduction of paymasters.
:check-icon Delve deeper into zkSync development with the introduction of paymasters.

:check-icon Learning how paymasters can cover transaction fees for your dApp users, enhancing accessibility and user experience.
:check-icon Learn how paymasters can cover transaction fees for your dApp users, enhancing accessibility and user experience.

:check-icon Discovering the flexibility of fee payment with paymasters, including the ability to pay
:check-icon Discover the flexibility of fee payment with paymasters, including the ability to pay
fees in ERC20 tokens on zkSync Era, using Hardhat or Foundry.

Embark on this journey to understand how paymasters can add a new layer of functionality and user-friendliness
to your decentralized applications.

### What are Paymasters?
## What are Paymasters?

Paymasters in the zkSync ecosystem represent a groundbreaking approach to handling transaction fees.
They are special accounts designed to subsidize transaction costs for other accounts, potentially making
certain transactions free for end-users. This feature is particularly useful for dApp developers looking
to improve their platform's accessibility and user experience by covering transaction fees on behalf of their users.

### Built-in Paymaster Flows
## Built-in Paymaster Flows

Paymasters can operate under various flows, some of which may require user interaction, such as setting allowances
for token swaps. These flows enable paymasters to support a wide range of use cases, from simple fee subsidies
to more complex scenarios involving ERC20 token exchanges for transaction fees.

- **General Paymaster Flow:** This default flow requires no preliminary actions from users, allowing paymasters
to interpret transaction data as needed to cover fees.

- **Approval-Based Paymaster Flow:** For operations requiring user permissions, such as token allowances,
this flow provides a structured approach. It ensures that user tokens can be seamlessly exchanged for transaction
fees, subject to user-approved limits.

As we delve into paymasters, remember that while they offer enhanced flexibility for fee management, their
As we explore paymasters, remember that while they offer enhanced flexibility for fee management, their
implementation should always prioritize security and user trust. This guide aims to equip you with the knowledge
to effectively incorporate paymasters into your zkSync projects, paving the way for more user-friendly and accessible dApps.

## Paymaster flow selection
## Paymaster flow

Select the paymaster type you want to get started using zkSync Era with.

Expand Down
Loading

0 comments on commit 0326651

Please sign in to comment.