diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 7482ab35..926f2429 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -17,16 +17,16 @@ jobs: - name: Runs Prettier Formatter run: bun run lint:prettier - # spelling: - # name: spelling - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: oven-sh/setup-bun@v1 - # - name: Install Dependencies - # run: bun install - # - name: Runs cSpell Spell Checker - # run: bun run lint:spelling + spelling: + name: spelling + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + - name: Install Dependencies + run: bun install + - name: Runs cSpell Spell Checker + run: bun run lint:spelling markdown-lint: name: markdown_lint @@ -49,3 +49,24 @@ jobs: run: bun install - name: Runs ESLint run: bun run lint:eslint + + link-check: + env: + NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }} + NUXT_PUBLIC_SITE_URL: ${{ secrets.NUXT_PUBLIC_SITE_URL }} + name: link_check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 # v4 + + - uses: oven-sh/setup-bun@v1 + + - name: "Install dependencies" + run: bun install + + - name: "Build site" + run: bun run build + + - uses: untitaker/hyperlink@0.1.32 + with: + args: .output/public/ --sources content/ diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 7c888389..be4e8750 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -29,11 +29,7 @@ jobs: run: bun install - name: "Deploy target: preview" - run: bun run generate - - - uses: untitaker/hyperlink@0.1.32 - with: - args: .output/public/ --sources content/ + run: bun run build - name: "Deploy preview" uses: matter-labs/action-hosting-deploy@main diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index e4bee2c8..ce6581e0 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -23,7 +23,7 @@ jobs: - name: "Install dependencies" run: bun install - name: "Deploy target: production 🚀" - run: bun run generate + run: bun run build # TODO: ask about below # env: # RUDDERSTACK_WRITE_KEY: "${{ secrets.RUDDERSTACK_WRITE_KEY }}" diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 9303be1c..c830d6bf 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -23,7 +23,7 @@ jobs: - name: "Install dependencies" run: bun install - name: "Deploy target: staging" - run: bun run generate + run: bun run build - uses: matter-labs/action-hosting-deploy@main with: diff --git a/README.md b/README.md index aaf6ac5a..0ecd9849 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Community Code -Welcome to the ZKsync Community Code repository. This project serves as the community hub for ZKsync, providing comprehensive +Welcome to the zkSync Community Code repository. This project serves as the community hub for zkSync, providing comprehensive documentation for developers written by developers. -Whether you're a beginner looking to get started with ZKsync or an experienced developer +Whether you're a beginner looking to get started with zkSync or an experienced developer seeking advanced guides, you'll find the resources you need here. ## Tools used diff --git a/content/_partials/_callout-zksync-cli.md b/content/_partials/_callout-zksync-cli.md new file mode 100644 index 00000000..99927845 --- /dev/null +++ b/content/_partials/_callout-zksync-cli.md @@ -0,0 +1,11 @@ +--- +title: Callout zkSync CLI +--- + +::callout{icon="i-heroicons-light-bulb"} +Skip the hassle for test ETH by using `zksync-cli` for local testing. +Simply execute `npx zksync-cli dev start` to initialize a local zkSync development environment, +which includes local Ethereum and zkSync nodes. +This method allows you to test contracts without requesting external testnet funds. +Explore more in the [zksync-cli documentation](https://docs.zksync.io/build/tooling/zksync-cli). +:: diff --git a/content/tutorials/another-guide/10.index.md b/content/tutorials/another-guide/10.index.md deleted file mode 100644 index 149ad038..00000000 --- a/content/tutorials/another-guide/10.index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Another Guide -description: Another guide to learn things. ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/another-guide/20.lets-do-something.md b/content/tutorials/another-guide/20.lets-do-something.md deleted file mode 100644 index 7a5d0e3e..00000000 --- a/content/tutorials/another-guide/20.lets-do-something.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Step 2 -description: The next step in the guide ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/another-guide/30.last-step.md b/content/tutorials/another-guide/30.last-step.md deleted file mode 100644 index cdb338d6..00000000 --- a/content/tutorials/another-guide/30.last-step.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Final Step -description: The last step to this guide. ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/another-guide/_info.yml b/content/tutorials/another-guide/_info.yml deleted file mode 100644 index 268648f3..00000000 --- a/content/tutorials/another-guide/_info.yml +++ /dev/null @@ -1,31 +0,0 @@ -title: Another Guide -authors: - - name: Jane Doe - url: https://example.com - avatar: https://avatars.githubusercontent.com/u/812331?v=4 - - name: John Doe - url: https://example.com - avatar: https://avatars.githubusercontent.com/u/812331?v=4 -github_repo: https://github.com/zkSync-Community-Hub -tags: - - web3 - - vyper -summary: This is a short description of the guide that will show up on tweets or previews. -description: - This is an extra long description that goes into more detail about the guide. It can be as long as you want, but it - should be a few sentences long. This is an extra long description that goes into more detail about the guide. It can - be as long as you want, but it should be a few sentences long. This is an extra long description that goes into more - detail about the guide. It can be as long as you want, but it should be a few sentences long. -what_you_will_learn: - - You'll learn how to make an example app - - You'll learn new tools - - ??? - - Profit! -updated: 2024-04-25 -tools: - - Git - - Docker - - zksync-cli - - Hardhat -related_tutorials: - - /tutorials/another-tutorial diff --git a/content/tutorials/best-tutorial/10.index.md b/content/tutorials/best-tutorial/10.index.md deleted file mode 100644 index b1da65a4..00000000 --- a/content/tutorials/best-tutorial/10.index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Best Tutorial -description: The best tutorial to learn from. ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/best-tutorial/20.next.md b/content/tutorials/best-tutorial/20.next.md deleted file mode 100644 index 81e43cfc..00000000 --- a/content/tutorials/best-tutorial/20.next.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Finish -description: We finish up the guide here. ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/best-tutorial/_info.yml b/content/tutorials/best-tutorial/_info.yml deleted file mode 100644 index 3c1cfbcf..00000000 --- a/content/tutorials/best-tutorial/_info.yml +++ /dev/null @@ -1,27 +0,0 @@ -title: Best Tutorial -authors: - - name: Jane Doe - url: https://example.com - avatar: https://avatars.githubusercontent.com/u/812331?v=4 -github_repo: https://github.com/zkSync-Community-Hub -tags: - - hardhat - - viem - - solidity -summary: This is a short description of the guide that will show up on tweets or previews. -description: - This is an extra long description that goes into more detail about the guide. It can be as long as you want, but it - should be a few sentences long. -what_you_will_learn: - - You'll learn how to make an example app - - You'll learn new tools - - ??? - - Profit! -updated: 2024-04-25 -tools: - - Git - - Docker - - zksync-cli - - Hardhat -related_tutorials: - - /tutorials/another-tutorial diff --git a/content/tutorials/cool-guide/10.index.md b/content/tutorials/cool-guide/10.index.md deleted file mode 100644 index b37d2903..00000000 --- a/content/tutorials/cool-guide/10.index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Cool Guide -description: Learn from the coolest guide. ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/cool-guide/20.next.md b/content/tutorials/cool-guide/20.next.md deleted file mode 100644 index 5213335c..00000000 --- a/content/tutorials/cool-guide/20.next.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Second Cool Step -description: The next step in the guide ---- - -## Bob Ross Quotes - -We'll put a happy little sky in here. With practice comes confidence. -If there's two big trees invariably sooner or later there's gonna be a little tree. We can fix anything. - -You have to allow the paint to break to make it beautiful. And maybe a little bush lives there. -Maybe there was an old trapper that lived out here and maybe one day he went to check his beaver traps, and maybe he fell into the river and drowned. -This is truly an almighty mountain. Happy painting, God bless. Trees grow in all kinds of ways. They're not all perfectly straight. Not every limb is perfect. - -Put your feelings into it, your heart, it's your world. The little tiny Tim easels will let you down. -Trees cover up a multitude of sins. That's crazy. But we're not there yet, so we don't need to worry about it. - -Let that brush dance around there and play. A little happy sunlight shining through there. -There we are. A beautiful little sunset. If I paint something, I don't want to have to explain what it is. -We have no limits to our world. We're only limited by our imagination. - -Pretend you're water. Just floating without any effort. Having a good day. Use absolutely no pressure. -Just like an angel's wing. As trees get older they lose their chlorophyll. - -Look around, look at what we have. Beauty is everywhere, you only have to look to see it. I get carried away with this brush cleaning. -I was blessed with a very steady hand; and it comes in very handy when you're doing these little delicate things. -It's beautiful - and we haven't even done anything to it yet. - -Let's have a nice tree right here. Little trees and bushes grow however makes them happy. -Each highlight must have it's own private shadow. No pressure. Just relax and watch it happen. -I really recommend you use odorless thinner or your spouse is gonna run you right out into the yard and you'll be working by yourself. -Exercising the imagination, experimenting with talents, being creative; these things, to me, are truly the windows to your soul. diff --git a/content/tutorials/cool-guide/_info.yml b/content/tutorials/cool-guide/_info.yml deleted file mode 100644 index 077b5404..00000000 --- a/content/tutorials/cool-guide/_info.yml +++ /dev/null @@ -1,28 +0,0 @@ -title: Cool Guide -authors: - - name: Jane Doe - url: https://example.com - avatar: https://avatars.githubusercontent.com/u/812331?v=4 -github_repo: https://github.com/zkSync-Community-Hub -tags: - - foundry - - solidity -summary: This is a short description of the guide that will show up on tweets or previews. -description: - This is an extra long description that goes into more detail about the guide. It can be as long as you want, but it - should be a few sentences long. This is an extra long description that goes into more detail about the guide. It can - be as long as you want, but it should be a few sentences long. This is an extra long description that goes into more - detail about the guide. It can be as long as you want, but it should be a few sentences long. -what_you_will_learn: - - You'll learn how to make an example app - - You'll learn new tools - - ??? - - Profit! -updated: 2024-04-25 -tools: - - Git - - Docker - - zksync-cli - - Hardhat -related_tutorials: - - /tutorials/another-tutorial diff --git a/content/tutorials/cross-chain-governance/10.index.md b/content/tutorials/cross-chain-governance/10.index.md new file mode 100644 index 00000000..14cfa54d --- /dev/null +++ b/content/tutorials/cross-chain-governance/10.index.md @@ -0,0 +1,225 @@ +--- +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. +--- + +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 + 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. + 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. +- 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"} + +### Complete Project + +Download the [complete project on GitHub](https://github.com/matter-labs/tutorials/tree/main/cross-chain). + +## Project Setup + +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. For now we will start with L1-governance +folder. + +```sh +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. +:: + +## L1 Governance + +1. `cd` into `L1-governance`. + +2. Run the following to initialise and set up the L1 project: + +```sh +npx hardhat +``` + +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: + +- Import it from the `@matterlabs/zksync-contracts` npm package (preferred). +- Download it from the [contracts repo](https://github.com/matter-labs/era-contracts). + +:: + +1. Install the following dependencies: + +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 +``` + +```bash [yarn] +yarn add -D typescript ts-node @openzeppelin/contracts @matterlabs/zksync-contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers +``` + +:: + +### Create L1 Governance Contract + +::callout{icon="i-heroicons-light-bulb"} +Make sure you're still in the `L1-governance` folder. +:: + +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. Remove existing `/test` directory and any contracts that exist in `/contracts`. + +2. `cd` into the `contracts/` folder. + +3. Create a file called `Governance.sol` and copy/paste the code below into it. + +```solidity [Governance.sol] +// SPDX-License-Identifier: Unlicense +pragma solidity ^0.8.13; + +import "@matterlabs/zksync-contracts/l1/contracts/zksync/interfaces/IZkSync.sol"; + +contract Governance { + address public governor; + + constructor() { + governor = msg.sender; + } + + function callZkSync( + address zkSyncAddress, + address contractAddr, + bytes memory data, + uint256 gasLimit, + uint256 gasPerPubdataByteLimit + ) external payable { + require(msg.sender == governor, "Only governor is allowed"); + + IZkSync zksync = IZkSync(zkSyncAddress); + zksync.requestL2Transaction{value: msg.value}(contractAddr, 0, + data, gasLimit, gasPerPubdataByteLimit, new bytes[](0), msg.sender); + } +} +``` + +### Deploy L1 Governance Contract + +1. Create the file `L1-Governance/sepolia.json` 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": "" + } + ``` + +1. Replace the code in `hardhat.config.ts` with the following: + + ```ts + import "@nomicfoundation/hardhat-ethers"; + import { HardhatUserConfig } from "hardhat/config"; + + // import file with Sepolia params + const sepolia = require("./sepolia.json"); + + const config: HardhatUserConfig = { + solidity: { + version: "0.8.20", + }, + networks: { + // Sepolia network + sepolia: { + url: sepolia.nodeUrl, + accounts: [sepolia.deployerPrivateKey], + }, + }, + }; + + export default config; + ``` + +1. Navigate to the `scripts` folder and copy/paste the following code into the `deploy.ts` file (removing any previous + code): + + ```ts + // We require the Hardhat Runtime Environment explicitly here. This is optional + // but useful for running the script in a standalone fashion through `node