diff --git a/content/tutorials/cross-chain-governance/10.index.md b/content/tutorials/cross-chain-governance/10.index.md index 0af07eb2..94e3be10 100644 --- a/content/tutorials/cross-chain-governance/10.index.md +++ b/content/tutorials/cross-chain-governance/10.index.md @@ -6,8 +6,9 @@ description: Build and deploy a smart contract in L1 and send transactions that 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 @@ -52,7 +53,7 @@ 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. @@ -73,11 +74,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 +131,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