From cb3d5eed2915345430694cef869fd95de037c680 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 22 Jul 2024 11:17:30 +0100 Subject: [PATCH] fix: broken tutorial --- .../cross-chain-governance/10.index.md | 96 ++++--- .../cross-chain-governance/20.L2-contract.md | 245 +----------------- .../30.cross-chain-transactions.md | 5 +- cspell-config/cspell-zksync.txt | 2 +- 4 files changed, 55 insertions(+), 293 deletions(-) diff --git a/content/tutorials/cross-chain-governance/10.index.md b/content/tutorials/cross-chain-governance/10.index.md index 14cfa54d..61b22cf6 100644 --- a/content/tutorials/cross-chain-governance/10.index.md +++ b/content/tutorials/cross-chain-governance/10.index.md @@ -1,25 +1,25 @@ --- title: L1 governance contract -description: Build and deploy a smart contract in L1 and send transactions that update the state of a contract in zkSync. +description: Build and deploy a smart contract in L1 and send transactions that update the state of a contract in ZKsync. --- This tutorial shows you how to implement communication between L1 and L2 with the following example: - A **Governance** Solidity smart contract is deployed on layer 1. This contract has a function that sends a transaction - to zkSync layer 2. -- A **Counter** Solidity smart contract is deployed on zkSync layer 2. This contract stores a number that is incremented + to ZKsync Era layer 2. +- A **Counter** Solidity smart contract is deployed on ZKsync Era layer 2. This contract stores a number that is incremented by calling the `increment` method. The `Governance` contract on layer 1 calls this function. ## Prerequisites - Make sure your machine satisfies the [system requirements](https://github.com/matter-labs/era-compiler-solidity/tree/main#system-requirements). -- You are already familiar with deploying smart contracts on zkSync Era. +- You are already familiar with deploying smart contracts on ZKsync Era. If not, please refer to the first section of the [quickstart tutorial](https://docs.zksync.io/build/quick-start). - You already have some experience working with Ethereum. - A wallet with sufficient Sepolia `%%zk_testnet_currency_symbol%%` on Ethereum and %%zk_testnet_name%% to pay for deploying smart contracts. You can get Sepolia ETH from the [network faucets](https://docs.zksync.io/ecosystem/network-faucets). - - Get testnet `ETH` for zkSync Era using [bridges](https://zksync.io/explore#bridges) to bridge funds to zkSync. + - Get testnet `ETH` for ZKsync Era using [bridges](https://zksync.io/explore#bridges) to bridge funds to ZKsync. - 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). :display-partial{path="/_partials/_callout-zksync-cli"} @@ -42,7 +42,7 @@ mkdir L1-governance ::callout{icon="i-heroicons-exclamation-circle"} The `L1-governance` code is a default Hardhat project used to deploy a contract on L1. -The `L2-counter` code includes all zkSync dependencies and configurations for L2. +The `L2-counter` code includes all ZKsync dependencies and configurations for L2. :: ## L1 Governance @@ -52,14 +52,14 @@ The `L2-counter` code includes all zkSync dependencies and configurations for L2 2. Run the following to initialise and set up the L1 project: ```sh -npx hardhat +npx hardhat init ``` Select the option **Create a Typescript project** and accept the defaults for everything else. ::callout{icon="i-heroicons-exclamation-circle"} -To interact with the zkSync bridge contract using Solidity, you need -the zkSync contract interface. There are two ways to get it: +To interact with the ZKsync bridge contract using Solidity, you need +the ZKsync contract interface. There are two ways to get it: - Import it from the `@matterlabs/zksync-contracts` npm package (preferred). - Download it from the [contracts repo](https://github.com/matter-labs/era-contracts). @@ -73,11 +73,11 @@ Make sure you use actual node (lts version) and actual npm version ::code-group ```bash [npm] -npm i -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers +npm i -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers dotenv ``` ```bash [yarn] -yarn add -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers +yarn add -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers dotenv ``` :: @@ -130,68 +130,52 @@ contract Governance { ### Deploy L1 Governance Contract -1. Create the file `L1-Governance/sepolia.json` and copy/paste the code below, filling in the relevant values. +1. Create the file `L1-Governance/.env` and copy/paste the code below, filling in the relevant values. Find node provider urls [here](https://chainlist.org/chain/11155111). You have to connect your wallet to the network and add the network to the wallet in advance. - ```json [L1-Governance/sepolia.json] - { - "nodeUrl": "", - "deployerPrivateKey": "" - } + ```txt [L1-Governance/.env] + NODE_RPC_URL= + PRIVATE_KEY= ``` 1. Replace the code in `hardhat.config.ts` with the following: ```ts - import "@nomicfoundation/hardhat-ethers"; import { HardhatUserConfig } from "hardhat/config"; + import "@nomicfoundation/hardhat-toolbox"; - // import file with Sepolia params - const sepolia = require("./sepolia.json"); + import dotenv from "dotenv"; + dotenv.config(); const config: HardhatUserConfig = { - solidity: { - version: "0.8.20", - }, + solidity: "0.8.24", networks: { - // Sepolia network - sepolia: { - url: sepolia.nodeUrl, - accounts: [sepolia.deployerPrivateKey], - }, - }, + // Sepolia network + sepolia: { + url: process.env.NODE_RPC_URL, + accounts: [process.env.PRIVATE_KEY as any], + }, + }, }; export default config; ``` -1. Navigate to the `scripts` folder and copy/paste the following code into the `deploy.ts` file (removing any previous - code): +1. Create the file `Governance.ts` inside the `/ignition/modules` folder and copy/paste the following code into it: ```ts - // We require the Hardhat Runtime Environment explicitly here. This is optional - // but useful for running the script in a standalone fashion through `node