Skip to content

Commit

Permalink
fix(docs): update readme files (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-bozin-txfusion authored Dec 22, 2023
1 parent 5384f53 commit 682338e
Show file tree
Hide file tree
Showing 19 changed files with 1,049 additions and 64 deletions.
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
# zkSync 2.0: Welcome to zkSync Hardhat plugins repository
# zkSync Era: Welcome to zkSync Hardhat plugins repository

![](https://user-images.githubusercontent.com/8230135/215079996-46ec1c91-e65d-4adb-8d7a-f7eecf851858.svg)
![Era Logo](https://github.com/matter-labs/era-contracts/raw/main/eraLogo.svg)

zkSync 2.0 is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or
zkSync Era is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or
decentralization. Since it's EVM compatible (Solidity/Vyper), 99% of Ethereum projects can redeploy without refactoring
or re-auditing a single line of code. zkSync 2.0 also uses an LLVM-based compiler that will eventually let developers
or re-auditing a single line of code. zkSync Era also uses an LLVM-based compiler that will eventually let developers
write smart contracts in C++, Rust and other popular languages.

This repository contains a collection of plugins to aid in the development and deployment of smart contracts on the zkSync network. These plugins are designed to integrate seamlessly with the [Hardhat](https://hardhat.org/) development environment, providing developers with an easy-to-use and powerful toolset.

Here is an overview of the plugins currently available:

**hardhat-zksync-solc**: This plugin is used to provide a convenient interface for compiling Solidity smart contracts before deploying them to the zkSync network.

**hardhat-zksync-deploy**: This plugin simplifies the deployment of your smart contracts to the zkSync network by providing utilities for deploying smart contracts with artifacts built by the zkSync hardhat-zksync-solc or hardhat-zksync-vyper plugins.

**hardhat-zksync-verify**: This plugin helps you to verify your smart contracts on the zkSync network by providing a set of tasks that automate the verification process.

**hardhat-zksync-verify-vyper**: This plugin helps you to verify your vyper smart contracts on the zkSync network by providing a set of tasks that automate the verification process.

**hardhat-zksync-vyper**: This plugin is used to provide a convenient interface for compiling Vyper smart contracts before deploying them to the zkSync network.

**hardhat-zksync-chai-matchers**: This plugin adds additional chai matchers to be used when writing tests with specific zkSync features.

**hardhat-zksync-toolbox**: This plugin provides a convenient method for bundling and accessing a range of zkSync-related Hardhat plugins.

**hardhat-zksync-upgradeable**: This plugin provides a convenient method to deploy and upgrade smart contracts on the zkSync network.

**hardhat-zksync-ethers**: This plugin is a wrapper around zksync-ethers sdk that gives additional methods to use for faster development.
| πŸ”Œ Plugin | πŸ“„ Description |
|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| hardhat-zksync-solc | Simplifies compiling Solidity contracts for the zkSync network, streamlining deployment preparation. |
| hardhat-zksync-deploy | Facilitates the deployment of contracts on zkSync, utilizing artifacts from hardhat-zksync-solc/vyper. |
| hardhat-zksync-verify | Automates the process of verifying smart contracts on the zkSync network, enhancing transparency and trust. |
| hardhat-zksync-verify-vyper | Specialized for automating the verification of Vyper contracts on the zkSync network. |
| hardhat-zksync-vyper | Streamlines the compilation of Vyper contracts for deployment on the zkSync network. |
| hardhat-zksync-chai-matchers | Extends chai with additional matchers, aiding in testing zkSync-specific features more effectively. |
| hardhat-zksync-toolbox | Offers a suite of zkSync-related Hardhat plugins in one package, enhancing accessibility and efficiency. |
| hardhat-zksync-upgradeable | Enables easier deployment and upgrading of smart contracts on the zkSync network, improving contract lifecycle management. |
| hardhat-zksync-ethers | A zksync-ethers SDK wrapper providing additional methods for accelerated development on zkSync. |

You can find more detailed explanations on how to use hardhat zkSync plugins on our [documentation page](https://v2-docs.zksync.io/api/hardhat/plugins.html#plugins) where each plugin has its own section:

Expand Down
4 changes: 2 additions & 2 deletions examples/basic-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 deploy environment example
# zkSync Era deploy environment example

This project demonstrates how to compile and deploy your contracts in zkSync 2.0 using the Hardhat plugins.
This project demonstrates how to compile and deploy your contracts in zkSync Era using the Hardhat plugins.

## Prerequisites

Expand Down
2 changes: 1 addition & 1 deletion examples/node-example/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# zkSync 2.0 node environment example
# zkSync Era node environment example

This project demonstrates how to run [era-test-node](https://era.zksync.io/docs/tools/testing/era-test-node.html) locally using the zksync's `hardhat-zksync-node` Hardhat plugin for testing purposes.

Expand Down
4 changes: 2 additions & 2 deletions examples/noninline-libraries-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 non-inline libraries environment example
# zkSync Era non-inline libraries environment example

This project demonstrates how to compile and deploy your contracts in zkSync 2.0 when there are missing libraries.
This project demonstrates how to compile and deploy your contracts in zkSync Era when there are missing libraries.

## Prerequisites

Expand Down
4 changes: 2 additions & 2 deletions examples/upgradable-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 upgradable example
# zkSync Era upgradable example

This project demonstrates how to compile and deploy upgadable smart contracts in zkSync 2.0 using the Hardhat plugins.
This project demonstrates how to compile and deploy upgadable smart contracts in zkSync Era using the Hardhat plugins.

## Prerequisites

Expand Down
4 changes: 2 additions & 2 deletions examples/verify-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 verify environment example
# zkSync Era verify environment example

This project demonstrates how to compile and verify your contracts in zkSync 2.0 using the Hardhat plugins.
This project demonstrates how to compile and verify your contracts in zkSync Era using the Hardhat plugins.

## Prerequisites

Expand Down
4 changes: 2 additions & 2 deletions examples/verify-vyper-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 verify vyper environment example
# zkSync Era verify vyper environment example

This project demonstrates how to compile and deploy your contracts in zkSync 2.0 using the Hardhat plugins.
This project demonstrates how to compile and deploy your contracts in zkSync Era using the Hardhat plugins.

## Prerequisites

Expand Down
4 changes: 2 additions & 2 deletions examples/vyper-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 vyper environment example
# zkSync Era vyper environment example

This project demonstrates how to compile and deploy your contracts in zkSync 2.0 using the Hardhat plugins.
This project demonstrates how to compile and deploy your contracts in zkSync Era using the Hardhat plugins.

## Prerequisites

Expand Down
4 changes: 2 additions & 2 deletions examples/zksync-ethers-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zkSync 2.0 zksync-ethers environment example
# zkSync Era zksync-ethers environment example

This project demonstrates how to compile and deploy your contracts in zkSync 2.0 using the Hardhat plugins.
This project demonstrates how to compile and deploy your contracts in zkSync Era using the Hardhat plugins.

## Prerequisites

Expand Down
98 changes: 95 additions & 3 deletions packages/hardhat-zksync-chai-matchers/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,97 @@
# hardhat-zksync-chai-matchers
# hardhat-zksync-chai-matchers πŸš€

[Hardhat](https://hardhat.org/) plugin that adds zkSync-specific capabilities to the [Chai](https://chaijs.com/) assertion library, making your smart contract tests easy to write and read.
zkSync Era's integration into the [Chai](https://chaijs.com/) assertion library is enabled by this [Hardhat](https://hardhat.org/) plugin, adding capabilities that make writing and reading smart contract tests easy."

Check out the documentation page for the [zksync chai matchers plugin](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-chai-matchers.html) for more detailed explanation on how to use hardhat-zksync-chai-matchers.
![Era Logo](https://github.com/matter-labs/era-contracts/raw/main/eraLogo.svg)

## ⚠️ Version Compatibility Warning

Ensure you are using the correct version of the plugin with ethers:
- For plugin version **<1.0.0**:
- Compatible with ethers **v5**.

- For plugin version **β‰₯1.0.0**:
- Compatible with ethers **v6** (⭐ Recommended)

## πŸ“₯ Installation

To install **hardhat-zksync-chai-matchers** plugin, run:

`npm install -D @matterlabs/hardhat-zksync-chai-matchers`

or

`yarn add -D @matterlabs/hardhat-zksync-chai-matchers @nomicfoundation/hardhat-chai-matchers chai @nomiclabs/hardhat-ethers ethers`

## πŸ“– Usage

After installing it, add the plugin to your Hardhat config:

`import "@matterlabs/hardhat-zksync-chai-matchers";`

Then you'll be able to use the matchers in your tests.

**changeEtherBalance**

Assert that the ether balance of an address changed by a specific amount:

```
await expect(() =>
sender.transfer({
to: receiver.address,
amount: 2000,
})
).to.changeEtherBalance(sender.address, -2000);
```

**changeTokenBalance**

Assert that an ERC20 token balance of an address changed by a specific amount:

```
await expect(sender.transfer({ to: receiver.address, amount: 5, token: token.address })).to.changeTokenBalance(token, sender, -5);
await expect(token.transfer(receiver.address, 5)).to.not.changeTokenBalance(token, sender, 0);
```

**revertedWithCustomError**

Assert that a transaction reverted with a specific custom error:

```
await expect(contract.setAmount(100)).to.be.reverted;
```

You can also use regular chai matchers like:


```
await expect(contract.setAmount(100)).to.emit(contract, "AmountUpdated");
expect("0x36615Cf349d7F6344891B1e7CA7C72883F5dc049").to.be.properAddress;
expect(await contract.getAmount()).to.equal(100);
```

## πŸ“ Documentation

In addition to the [hardhat-zksync-chai-matchers](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-chai-matchers.html), zkSync's Era [website](https://era.zksync.io/docs/) offers a variety of resources including:

[Guides to get started](https://era.zksync.io/docs/dev/building-on-zksync/hello-world.html): Learn how to start building on zkSync Era.\
[Hardhat zkSync Era plugins](https://era.zksync.io/docs/tools/hardhat/getting-started.html): Overview and guides for all Hardhat zkSync Era plugins.\
[Hyperscaling](https://era.zksync.io/docs/reference/concepts/hyperscaling.html#what-are-hyperchains): Deep dive into hyperscaling on zkSync Era.

## 🀝 Contributing

Contributions are always welcome! Feel free to open any issue or send a pull request.

Go to [CONTRIBUTING.md](https://github.com/matter-labs/hardhat-zksync/blob/main/.github/CONTRIBUTING.md) to learn about steps and best practices for contributing to zkSync hardhat tooling base repository.


## πŸ™Œ Feedback, help and news

[zkSync Era Discord server](https://join.zksync.dev/): for questions and feedback.\
[Follow zkSync Era on Twitter](https://twitter.com/zksync)

## Happy building!
169 changes: 166 additions & 3 deletions packages/hardhat-zksync-deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,169 @@
# hardhat-zksync-deploy
## hardhat-zksync-deploy πŸš€

[Hardhat](https://hardhat.org/) plugin that adds zkSync-specific capabilities to deploy contracts into the zkSync network.
zkSync Era capabilities for contract deployment are enhanced with this [Hardhat](https://hardhat.org/) plugin, specifically designed to add zkSync-specific features to the network.

![Era Logo](https://github.com/matter-labs/era-contracts/raw/main/eraLogo.svg)

Check out the documentation page for the [zksync deploy plugin](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-deploy.html) for more detailed explanation on how to use hardhat-zksync-deploy.
This plugin provides utilities for deploying smart contracts on zkSync Era with artifacts built by the [@matterlabs/hardhat-zksync-solc](https://www.npmjs.com/package/@matterlabs/hardhat-zksync-solc) or [@matterlabs/hardhat-zksync-vyper](https://www.npmjs.com/package/@matterlabs/hardhat-zksync-vyper) plugins.

## ⚠️ Version Compatibility Warning

Ensure you are using the correct version of the plugin with ethers:
- For plugin version **<1.0.0**:
- Compatible with ethers **v5**.

- For plugin version **β‰₯1.0.0**:
- Compatible with ethers **v6** (⭐ Recommended)

## πŸ“£ Prerequisite

- You are already familiar with deploying smart contracts on zkSync Era. If not, please refer to the first section of the [quickstart tutorail](https://era.zksync.io/docs/dev/building-on-zksync/hello-world.html).
- You have a wallet with sufficient Sepolia or Goerli **ETH** on L1 to pay for bridging funds to zkSync as well as deploying smart contracts. Use the third party faucets to get some test tokens in your account.
- You know how to get your [private key from your MetaMask wallet](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key).

## πŸ“₯ Installation

To install **hardhat-zksync-deploy** plugin, run:

`npm install -D @matterlabs/hardhat-zksync-deploy`

or

`yarn add -D @matterlabs/hardhat-zksync-deploy ethers zksync-ethers`


## πŸ“€ Exports

The main export of this plugin is the Deployer class. It is used to wrap a zksync-ethers Wallet instance and provides a convenient interface to deploy smart contracts and account abstractions.
It's main methods are:

```
* @param hre Hardhat runtime environment. This object is provided to scripts by hardhat itself.
* @param zkWallet The wallet which will be used to deploy the contracts.
* @param deploymentType Optional deployment type that relates to the ContractDeployer system contract function to be called. Defaults to deploying regular smart contracts.
```
- `constructor(hre: HardhatRuntimeEnvironment, zkWallet: zk.Wallet, deploymentType?: zk.types.DeploymentType)`

```
* Created a `Deployer` object on ethers.Wallet object.
*
* @param hre Hardhat runtime environment. This object is provided to scripts by hardhat itself.
* @param ethWallet The wallet used to deploy smart contracts.
* @param deploymentType The optional deployment type that relates to the `ContractDeployer` system contract function to be called. Defaults to deploying regular smart contracts.
```
- `static fromEthWallet(hre: HardhatRuntimeEnvironment, ethWallet: ethers.Wallet, deploymentType?: zk.types.DeploymentType)`

```
* Loads an artifact and verifies that it was compiled by `zksolc`.
*
* @param contractNameOrFullyQualifiedName The name of the contract.
* It can be a bare contract name (e.g. "Token") if it's
* unique in your project, or a fully qualified contract name
* (e.g. "contract/token.sol:Token") otherwise.
*
* @throws Throws an error if a non-unique contract name is used,
* indicating which fully qualified names can be used instead.
*
* @throws Throws an error if an artifact was not compiled by `zksolc`.
```
- `public async loadArtifact(contractNameOrFullyQualifiedName: string): Promise<ZkSyncArtifact>`

```
* Estimates the price of calling a deploy transaction in a certain fee token.
*
* @param artifact The previously loaded artifact object.
* @param constructorArguments The list of arguments to be passed to the contract constructor.
*
* @returns Calculated fee in ETH wei.
*/
```
- `public async estimateDeployFee(artifact: ZkSyncArtifact,constructorArguments: any[]): Promise<ethers.BigNumber>`

```
* Sends a deploy transaction to the zkSync network.
* For now it uses defaults values for the transaction parameters:
*
* @param artifact The previously loaded artifact object.
* @param constructorArguments The list of arguments to be passed to the contract constructor.
* @param overrides Optional object with additional deploy transaction parameters.
* @param additionalFactoryDeps Additional contract bytecodes to be added to the factory dependencies list.
* The fee amount is requested automatically from the zkSync Era server.
*
* @returns A contract object.
```
- `public async deploy(artifact: ZkSyncArtifact,constructorArguments: any[],overrides?: OverridesadditionalFactoryDeps?: ethers.BytesLike[],): Promise<zk.Contract>`

```
* Extracts factory dependencies from the artifact.
*
* @param artifact Artifact to extract dependencies from
*
* @returns Factory dependencies in the format expected by SDK.
```
- `async extractFactoryDeps(artifact: ZkSyncArtifact): Promise<string[]>`

## πŸ“– Example

After installing it, add the plugin to your Hardhat config:

`import "@matterlabs/hardhat-zksync-deploy";`

Then you'll be able to use the Deployer class in your files.

Create your script in **deploy** folder,

Import Deployer like this:

`import { Deployer } from '@matterlabs/hardhat-zksync-deploy';`

or

`const { Deployer } = require('@matterlabs/hardhat-zksync-deploy');`

Create a deployer instance:

`const deployer = new Deployer(hre, zkWallet);`

Note:
- **hre** - hardhat runtime enviroment
- **zkWallet** - instace of Wallet using [zksync-ethers](https://www.npmjs.com/package/zksync-ethers) plugin

Load your contract artifacts:

`const artifact = await deployer.loadArtifact('Greeter');`

Deploy your contract:

`const myContract = await deployer.deploy(artifact, [...contractArguments]);`

Check the deployed address:

`const address = await myContract.getAddress()`

## πŸ•Ή Commands

`yarn hardhat deploy-zksync` -- runs through all the scripts in the **deploy** folder.\
`hardhat deploy-zksync --script script-name.ts` -- run a specific script from **deploy** folder.\
`yarn hardhat deploy-zksync:libraries --private-key <PRIVATE_KEY>` -- uns compilation and deployment of missing libraries (the list of all missing libraries is provided by the output of [matterlabs/hardhat-zksync-solc](https://www.npmjs.com/package/@matterlabs/hardhat-zksync-solc) plugin). Read more about how zkSync deals with libraries on this [link](https://era.zksync.io/docs/tools/hardhat/compiling-libraries.html).

## πŸ“ Documentation

In addition to the [hardhat-zksync-deploy](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-deploy.html), zkSync's Era [website](https://era.zksync.io/docs/) offers a variety of resources including:

[Guides to get started](https://era.zksync.io/docs/dev/building-on-zksync/hello-world.html): Learn how to start building on zkSync Era.\
[Hardhat zkSync Era plugins](https://era.zksync.io/docs/tools/hardhat/getting-started.html): Overview and guides for all Hardhat zkSync Era plugins.\
[Hyperscaling](https://era.zksync.io/docs/reference/concepts/hyperscaling.html#what-are-hyperchains): Deep dive into hyperscaling on zkSync Era.

## 🀝 Contributing

Contributions are always welcome! Feel free to open any issue or send a pull request.

Go to [CONTRIBUTING.md](https://github.com/matter-labs/hardhat-zksync/blob/main/.github/CONTRIBUTING.md) to learn about steps and best practices for contributing to zkSync hardhat tooling base repository.


## πŸ™Œ Feedback, help and news

[zkSync Era Discord server](https://join.zksync.dev/): for questions and feedback.\
[Follow zkSync Era on Twitter](https://twitter.com/zksync)

## Happy building! πŸ‘·β€β™€οΈπŸ‘·β€β™‚οΈ
Loading

0 comments on commit 682338e

Please sign in to comment.