Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into tooling/web3.js/plugin-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danforbes authored Feb 22, 2024
2 parents 4704ed9 + 1c74f28 commit aaf40b4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 56 deletions.
2 changes: 1 addition & 1 deletion docs/build/quick-start/add-zksync-to-metamask.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Fill in the following details for the zkSync network:

## Mainnet network info

- Network Name: `zkSync Era Mainnet
- Network Name: `zkSync Era Mainnet`
- RPC URL: `https://mainnet.era.zksync.io`
- Chain ID: `324`
- Currency Symbol: `ETH`
Expand Down
6 changes: 1 addition & 5 deletions docs/build/support/audit-bug-bounty.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ Here is the list of **completed audits**:
- [ZK Proof System](https://github.com/HalbornSecurity/PublicReports/blob/master/ZK%20Audits/MatterLabs_zkSync_Era_Circuits_Zero_Knowledge_Security_Audit_Report_Halborn_Final..pdf), Halborn, from 2023-01-09 to 2023-03-08.
- [Smart Contract Security Assessment](https://github.com/HalbornSecurity/PublicReports/blob/master/Solidity%20Smart%20Contract%20Audits/MatterLabs_Verifier_Smart_Contract_Security_Assessment_Report_Halborn_Final.pdf), Halborn, from July 12th, 2023 - July 20th, 2023.
- [SNARK Wrapper](https://github.com/spearbit/portfolio/blob/master/pdfs/Matter-labs-snark-wrapper-Spearbit-Security-Review.pdf), Spearbit, November 2023

We've also scheduled the following audits:

- Layer 1 and Layer 2 Smart Contracts, Nov 2023, more details to follow.
- ZK Proof System, Nov 2023, more details to follow.
- [EIP-4844 Support](https://blog.openzeppelin.com/eip-4844-support-audit), OpenZeppelin, February 2024

## Bug Bounty Program

Expand Down
16 changes: 0 additions & 16 deletions docs/build/tutorials/how-to/send-transaction-l1-l2.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,29 +235,13 @@ User needs to perform next steps:

1. Run local node dockerized containers. [`Instructions how to run it`](https://github.com/matter-labs/local-setup/tree/main) or use [`zksync-cli`](https://github.com/matter-labs/zksync-cli):

::: code-tabs
@tab npx

```npx
npx zksync-cli dev config
// choose: Dockerized node - Persistent state, includes L1 and L2 nodes
// choose: BE and Portal (optional)
npx zksync-cli dev start
```

@tab npm

```npm
// install zksync-cli
npm i -g zksync-cli
zksync-cli dev config
// choose: Dockerized node - Persistent state, includes L1 and L2 nodes
// choose: BE and Portal (optional)
zksync-cli dev start
```

:::

2. In the root folder of the imported project (step 1) create `file.js` and insert there code from example below
3. In the root folder add `.env` file with private key of wallet to use

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Download the complete project [here](https://github.com/matter-labs/tutorials/tr

Open a terminal window, create a new folder for the project tutorial, e.g. `mkdir cross-chain-tutorial`, and `cd` into the folder.

Now create separate folders to store contracts and scripts on L1 and L2.
Now create separate folders to store contracts and scripts on L1 and L2. For now we will start with L1-governance folder.

```sh
mkdir L1-governance L2-counter
mkdir L1-governance
```

::: note
Expand Down Expand Up @@ -71,13 +71,13 @@ Make sure you use actual node (lts version) and actual npm version
@tab yarn

```sh
yarn add -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomiclabs/hardhat-ethers @nomiclabs/hardhat-waffle ethereum-waffle
yarn add -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers
```

@tab npm

```sh
npm i -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomiclabs/hardhat-ethers @nomiclabs/hardhat-waffle ethereum-waffle
npm i -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers
```

:::
Expand All @@ -92,9 +92,11 @@ The following Solidity code defines the Governance smart contract.

The constructor sets the contract creator as the single governor. The `callZkSync` function calls a transaction on L2 which can only be called by the governor.

1. `cd` into the `contracts\` folder and remove any files already there, if any.
1. Remove existing `/test` directory and any contracts that exist in `/contracts`.

2. Create a file called `Governance.sol` and copy/paste the code below into it.
2. `cd` into the `contracts\` folder.

3. Create a file called `Governance.sol` and copy/paste the code below into it.

```sol
// SPDX-License-Identifier: Unlicense
Expand Down Expand Up @@ -150,18 +152,17 @@ contract Governance {
2. Replace the code in `hardhat.config.ts` with the following:

```ts
import "@nomicfoundation/hardhat-ethers";
import { HardhatUserConfig } from "hardhat/config";
import "@nomiclabs/hardhat-waffle";

// import file with Sepolia params
const sepolia = require("./sepolia.json");

// Or, import file with Göerli params
// const goerli = require("./goerli.json");

const config: HardhatUserConfig = {
solidity: {
version: "0.8.19",
version: "0.8.20",
},
networks: {
// Sepolia network
Expand Down Expand Up @@ -195,9 +196,9 @@ async function main() {
const Governance = await ethers.getContractFactory("Governance");

const contract = await Governance.deploy();
await contract.deployed();
const receipt = await contract.deploymentTransaction()?.wait();

console.log(`Governance contract was successfully deployed at ${contract.address}`);
console.log(`Governance contract was successfully deployed at ${receipt?.contractAddress}`);
}

// We recommend always using this async/await pattern to properly handle errors.
Expand Down Expand Up @@ -244,10 +245,10 @@ Save the address to use in a later step.

Now that we have an address for the L1 governance contract, we can build, deploy, and test the counter contract on L2.

1. `cd` into `/L2-counter` and initialize the project:
1. `cd` out of `L1-governance` and initialize the `L2-counter` project:

```sh
npx zksync-cli create . --template hardhat_solidity
npx zksync-cli create L2-counter --template hardhat_solidity
```

::: tip
Expand Down Expand Up @@ -277,7 +278,7 @@ This contract contains the address of the governance contract deployed previousl
```sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;
pragma solidity ^0.8.20;
contract Counter {
uint256 public value = 0;
Expand Down Expand Up @@ -323,6 +324,9 @@ npx hardhat compile
import { utils, Wallet } from "zksync-ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
// load env file
import dotenv from "dotenv";
dotenv.config();

// Insert the address of the governance contract
const GOVERNANCE_ADDRESS = "<GOVERNANCE-ADDRESS>";
Expand All @@ -331,29 +335,23 @@ const GOVERNANCE_ADDRESS = "<GOVERNANCE-ADDRESS>";
export default async function (hre: HardhatRuntimeEnvironment) {
console.log(`Running deploy script for the Counter contract`);

const PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY || "";
if (!PRIVATE_KEY) throw "⛔️ Private key not detected! Add it to the .env file!";
// Initialize the wallet.
const wallet = new Wallet("<WALLET-PRIVATE-KEY>");
const wallet = new Wallet(PRIVATE_KEY);

// Create deployer object and load the artifact of the contract you want to deploy.
const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("Counter");

// Deposit some funds to L2 to be able to perform deposits.
const deploymentFee = await deployer.estimateDeployFee(artifact, [utils.applyL1ToL2Alias(GOVERNANCE_ADDRESS)]);
const depositHandle = await deployer.zkWallet.deposit({
to: deployer.zkWallet.address,
token: utils.ETH_ADDRESS,
amount: deploymentFee.mul(2),
});
// Wait until the deposit is processed on zkSync
await depositHandle.wait();

// Deploy this contract. The returned object will be of a `Contract` type, similar to the ones in `ethers`.
// The address of the governance is an argument for contract constructor.
const counterContract = await deployer.deploy(artifact, [utils.applyL1ToL2Alias(GOVERNANCE_ADDRESS)]);

const receipt = await counterContract.deploymentTransaction()?.wait();

// Show the contract info.
const contractAddress = counterContract.address;
const contractAddress = receipt?.contractAddress;
console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
}
```
Expand Down Expand Up @@ -517,18 +515,26 @@ You have to copy only abi content from the file after the keyword abi, an exampl
- RPC-URL: the same url you used in the `sepolia.json` or `goerli.json` file.

```ts
import { BigNumber, Contract, ethers, Wallet } from "ethers";
import { Contract, Wallet, Interface } from "ethers";
import { Provider, utils } from "zksync-ethers";
// load env file
import dotenv from "dotenv";
dotenv.config();

const GOVERNANCE_ABI = require("./governance.json");
const GOVERNANCE_ADDRESS = "<GOVERNANCE-ADDRESS>";
const COUNTER_ABI = require("./counter.json");
const COUNTER_ADDRESS = "<COUNTER-ADDRESS>";

const PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY || "";
if (!PRIVATE_KEY) throw "⛔️ Private key not detected! Add it to the .env file!";
// Initialize the wallet.

async function main() {
// Enter your Ethereum L1 provider RPC URL.
const l1Provider = new ethers.providers.JsonRpcProvider("<RPC-URL>");
const l1Provider = new Provider("<L1-RPC-URL>");
// Set up the Governor wallet to be the same as the one that deployed the governance contract.
const wallet = new ethers.Wallet("<YOUR-PRIVATE-KEY>", l1Provider);
const wallet = new Wallet(PRIVATE_KEY, l1Provider);
// Set a constant that accesses the Layer 1 contract.
const govcontract = new Contract(GOVERNANCE_ADDRESS, GOVERNANCE_ABI, wallet);

Expand All @@ -539,9 +545,9 @@ async function main() {
// Get the `Contract` object of the zkSync bridge.
const zkSyncContract = new Contract(zkSyncAddress, utils.ZKSYNC_MAIN_ABI, wallet);

// Encoding the L2 transaction is done in the same way as it is done on Ethereum.
// Encoding the L1 transaction is done in the same way as it is done on Ethereum.
// Use an Interface which gives access to the contract functions.
const counterInterface = new ethers.utils.Interface(COUNTER_ABI);
const counterInterface = new Interface(COUNTER_ABI);
const data = counterInterface.encodeFunctionData("increment", []);

// The price of an L1 transaction depends on the gas price used.
Expand All @@ -555,7 +561,7 @@ async function main() {
caller: utils.applyL1ToL2Alias(GOVERNANCE_ADDRESS),
});
// baseCost takes the price and limit and formats the total in wei.
// For more information on `REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT` see the [fee model documentation](../../reference/concepts/fee-model.md).
// For more information on `REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT` see the [fee model documentation](../developer-guides/transactions/fee-model.md).
const baseCost = await zkSyncContract.l2TransactionBaseCost(gasPrice, gasLimit, utils.REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT);

// !! If you don't include the gasPrice and baseCost in the transaction, a re-estimation of fee may generate errors.
Expand Down
5 changes: 3 additions & 2 deletions docs/zk-stack/running-a-hyperchain/locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ git clone https://github.com/matter-labs/zksync-era
2. Add `ZKSYNC_HOME` to your path (e.g. `~/.bash_profile`, `~/.zshrc` ) - don't forget to source your profile file again (or restart your terminal):

```bash
export ZKSYNC_HOME=/path/to/zksync/repo/you/cloned export PATH=$ZKSYNC_HOME/bin:$PATH
export ZKSYNC_HOME=/path/to/zksync/repo/you/cloned
export PATH=$ZKSYNC_HOME/bin:$PATH
```

3. Build latest version of zk tools by just running `zk` on the root of the project.
Expand Down Expand Up @@ -144,7 +145,7 @@ There are two options for running the Boojum prover: in GPU, or in CPU.

The docker compose file assumes you will be running all components in the same machine. The current minimum requirements for a low TPS scenario are:

- 16 GB VRAM NVIDIA GPU
- 6 GB VRAM NVIDIA GPU
- 16 Core CPU
- 64 GB of RAM
- 300 GB of Disk Space (SSD preferred)
Expand Down

0 comments on commit aaf40b4

Please sign in to comment.