# 如何在zksync 2.0测试网上部署合约并拿到gitpoap

By [Newbee740](https://paragraph.com/@newbee740) · 2023-02-14

---

首先介绍一下基础环境,默认各位看官都拥有一个github账号并且熟悉基础git操作,和一个有goerli水的钱包地址及对应私钥.基础问题自行谷歌解决

打开L2研讨会项目的github地址.

[https://github.com/matter-labs/l2-intro-pre-ethdenver](https://github.com/matter-labs/l2-intro-pre-ethdenver)

下载代码
----

第一步,右上角点击fork,分叉该项目到自己的github仓库中

![](https://storage.googleapis.com/papyrus_images/527ac31572485cbf040b6fb9e9bef896fbd0b35ce90d4713e6b5c75fe09108f4.png)

![](https://storage.googleapis.com/papyrus_images/1013440325a43e27e811991c09709f3c0b7a894acc1048822b5a7a4e052261fc.png)

完成后会跳转到分叉后的项目中.在如下位置复制git仓库地址

![](https://storage.googleapis.com/papyrus_images/7dde87aa955c142eb4665d1ed4c47a4a0942fe42a339b6ca6d2a4f50114b7067.png)

clone到本地 git clone +复制的地址复制到本地(本地需安装好git环境,可自行谷歌解决)

![](https://storage.googleapis.com/papyrus_images/f9c101e592b7adaf629b449776ac5adad83e31aae7deb7468c9574e905569fef.png)

部署合约
----

使用熟悉的代码编辑器打开项目文件夹,并做如下修改,私钥不需要0x开头

![](https://storage.googleapis.com/papyrus_images/8e2ac7648df075725559ea84ce436d05bd3ab460eee9e5e7ee0c52bc16b42773.png)

安装hardhat(需要npm环境和yarn管理包,自行谷歌解决)

![](https://storage.googleapis.com/papyrus_images/cb9e029ca44729ad254b2abaf296d07419526b67138ec0a08b41a3d29d6fa9d4.png)

编译项目

![](https://storage.googleapis.com/papyrus_images/ba303a6cec2c8164a2c77d63eed746e3446805154199dc669a9d2af72f915ef6.png)

![](https://storage.googleapis.com/papyrus_images/d3f27399be45b5189cb06244c1fa0e264d64a874403ca30b2551986371a4f380.png)

部署合约到测试网(会存在网络问题,多试几次),记住构造参数和合约地址

![](https://storage.googleapis.com/papyrus_images/2dc909c7bd2f9d48988714129a135fb06a6b10ac9f6894346f8a4d792dd0ed00.png)

验证合约
----

在2.0测试网中搜索自己的合约地址

[https://goerli.explorer.zksync.io/](https://goerli.explorer.zksync.io/)

选择contract,会出现一个verify的按钮,点击它(忘截图了)

![](https://storage.googleapis.com/papyrus_images/d7a1c184795ccd56d0fc26f52afcc6693feba520cead48bc0e80abd60102bc5e.png)

然后填好如下信息

![](https://storage.googleapis.com/papyrus_images/e753178b16fbc01281f4dc05cf278c6bac5bd8fb510a672b6cfad26dce472b62.png)

源代码在Greeter.sol文件里

![](https://storage.googleapis.com/papyrus_images/6f0cd8711525a22f370422d5dea43d0e11b50dc0d67ba2f93de37e4475c7dad1.png)

版本信息在hardhat.config.ts文件里

![](https://storage.googleapis.com/papyrus_images/7fbe9a52767d4a1a8ac8e6e3b617e08102245fc3aed78bf5124f4aa6d47f4e5e.png)

点击verify,验证成功后可以看到如下界面,可以连上自己钱包做几笔tx

![](https://storage.googleapis.com/papyrus_images/b40010c75fec1b9cddee036265ba6fcbce1af586f1efe69b25c71e4925a9b7dc.png)

申请gitpoap
---------

合约做好后,在Deployments.md文件中按照格式添加一行

\\合约地址\\

![](https://storage.googleapis.com/papyrus_images/3119e1c9ad951f06852d08fbabeadbd27ae5e60ab70df7db446519bdb582b8dc.png)

保存之后git三连,上传到git仓库里

    git add.
    git commit -m “update“
    git push
    

![](https://storage.googleapis.com/papyrus_images/f60415c22d2afcf7115c395dd926fef5ff17f7c3b0e0fb5d3317d17678efc643.png)

然后打开原项目方的仓库地址

[https://github.com/matter-labs/l2-intro-pre-ethdenver](https://github.com/matter-labs/l2-intro-pre-ethdenver)

创建一个pr

![](https://storage.googleapis.com/papyrus_images/563a78e8b8ed33d397b74afebde035575db79149080537ea01273fb2498c7cc7.png)

点击Create pull request

![](https://storage.googleapis.com/papyrus_images/1754f775ee84cb4b29ddea62f132ccb49179356409c3c9c2f20a1c1e950c831a.png)

继续

![](https://storage.googleapis.com/papyrus_images/8ca999cf3cd71ba064abdce188e6835c6fef39da2e49beeb9176cd7e5cb6120c.png)

完成,等待审核

![](https://storage.googleapis.com/papyrus_images/6595d9a209be24f64fada5331e3508df61418c43a4aafd90d026d78572168c8c.png)

领取gitpoap
---------

在该网站连接自己想领取gitpoap的钱包地址,然后连接刚刚使用的github地址

[https://www.gitpoap.io/](https://www.gitpoap.io/)

点击检查,需要等审核过后

![](https://storage.googleapis.com/papyrus_images/5abd3c6f61bbc6bb9d1a4295eab6ebaafcc35638f11aed1347ae578437411296.png)

![](https://storage.googleapis.com/papyrus_images/582548631eac99c11d03d479dbdfd3ab29eb48e163eab91ff7894c8b233fd08e.png)

结尾
--

点个关注,点个爱心,谢谢家人们了
----------------

[https://twitter.com/newbee740](https://twitter.com/newbee740)

![](https://storage.googleapis.com/papyrus_images/52931a853dd3bb62444738cd18cd20b56109fb07db1d45d8571b6eac662be306.png)

---

*Originally published on [Newbee740](https://paragraph.com/@newbee740/zksync-2-0-gitpoap)*
