<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Licrazy</title>
        <link>https://paragraph.com/@doger</link>
        <description>undefined</description>
        <lastBuildDate>Fri, 15 May 2026 11:48:19 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Licrazy</title>
            <url>https://storage.googleapis.com/papyrus_images/eef749b68022e373ade6dee906dd5e5430e4135e109152b668f3319cc39f1961.jpg</url>
            <link>https://paragraph.com/@doger</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Condor System 任务8-2：Decentralized Staking App]]></title>
            <link>https://paragraph.com/@doger/condor-system-8-2-decentralized-staking-app</link>
            <guid>8OJtXpnK43fP0YbYVGqt</guid>
            <pubDate>Sat, 08 Oct 2022 06:57:29 GMT</pubDate>
            <description><![CDATA[我的推特：LiCrazy，在此要感谢社区的 @WSHannn.eth#6958 大佬给我启发。 TL;DR：Copy别人合约代码部署一个staking dapp，copy大法好啊，几个命令就搞定。但貌似审核程序有bug同样的操作可能要几次才能通过，有点靠运气，so你们通不过也不要问我，我也是重复了四五次才侥幸通过。o(╥﹏╥)o一、准备工作1、老样子，去https://speedrunethereum.com/challenge/decentralized-staking 找到“open in gitpod”打开代码库，坐等加载完，需要一定的时间。 许多人不知道如何打开/登陆Gitpod，拜托这就像你天天登陆微信一样简单，别再问了好吗？╮(╯▽╰)╭加载完大概是下面这个鬼样子，是不是很面熟，是的就是这么巧，我又来了。二、修改代码这次我打算偷点懒不会写的那么保姆级了，你们爱懂不懂（指关节昨晚有点痛）。 1、既然要用copy大法我们先找到大神的合约代码。ding的一下，找到了：https://goerli.etherscan.io/address/0x23bcf7e1a822e564...]]></description>
            <content:encoded><![CDATA[<p>我的推特：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/0xFeng">LiCrazy</a>，在此要感谢社区的 @WSHannn.eth#6958 大佬给我启发。</p><p>TL;DR：Copy别人合约代码部署一个staking dapp，copy大法好啊，几个命令就搞定。但貌似审核程序有bug同样的操作可能要几次才能通过，有点靠运气，so你们通不过也不要问我，我也是重复了四五次才侥幸通过。o(╥﹏╥)o</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">一、准备工作</h3><p>1、老样子，去<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://speedrunethereum.com/challenge/decentralized-staking">https://speedrunethereum.com/challenge/decentralized-staking</a> 找到“open in gitpod”打开代码库，坐等加载完，需要一定的时间。</p><p>许多人不知道如何打开/登陆<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://gitpod.io/">Gitpod</a>，拜托这就像你天天登陆微信一样简单，别再问了好吗？╮(╯▽╰)╭</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/aadb8ff1b0e808d7667afde7bf8b6aa7bcd1e6e565e57060e07963537084be76.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>加载完大概是下面这个鬼样子，是不是很面熟，是的就是这么巧，我又来了。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a2c713df8a0fa07cb38a43ed301bd6488d7e098589ddca36905b9b5e5a66c8b7.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">二、修改代码</h3><p>这次我打算偷点懒不会写的那么保姆级了，你们爱懂不懂（指关节昨晚有点痛）。</p><p>1、既然要用copy大法我们先找到大神的合约代码。ding的一下，找到了：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerli.etherscan.io/address/0x4606179db6c13f97789a35BE516BF8740F147285#code">https://goerli.etherscan.io/address/0x23bcf7e1a822e5645b497cfa111bf89e129cef8f#code</a> 为啥我能这么快找到？因为这就是我的代码。^_^</p><p>看到下图这三坨代码没？不管你看到没，反正记下来等下要copy到Gitpod里面去。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5050d93f77a42552a0d813de1d796e2592952dc4309eff42c56e26eb2078f22c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、打开Packages文件夹下的hardhat文件夹，这次我们一次性搞定四个文件的修改，怕了么。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1f2f5f185c3a1a0856efc3e06704a156f8e872555ac9285a2247e79e6efebd68.png" alt="是不是抱怨这张图字有点模糊，请你点放大，享受高清AV画质" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">是不是抱怨这张图字有点模糊，请你点放大，享受高清AV画质</figcaption></figure><p>3、打开packages/react-app/src/App.jsx文件，把里面targetNetwork改成goerli，又是好熟悉的操作，要不要截个图呢？你猜我截不截。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/dde2f8c9401845742ac334e9abac3d9126efbcdf742a59a0855c3c69aed51522.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-goerli" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">三、在Goerli网络部署合约</h3><p>1、在terminal控制台输入yarn run generate创建一个钱包地址，并转入少量goerliETH进去做gas。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/19796cf7fa0173a9bf06f76aaf1cbeb76f009aabd0d3e94b0e4b01e99ead9ecd.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、在Terminal控制台输入yarn deploy --reset部署合约代码,红框2为我们部署的合约。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9e07b1ade502c0ef5bf2c84fa247d5bb7f6f3165db0f224ff501aa33becd1475.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">四、部署前端</h3><p>1、在Terminal控制台输入yarn build,创建前端，需要等待较长的时间，如下图显示即为成功。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/65f9f634e9b081e76da38e9848089b5f8de5622b4a1f92929fb0174ff8f6469a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、在Terminal控制台输入yarn surge，期间让会让你输入邮箱/密码创建surge账号，输入后每次回车即可。当出现domaim网址后再次回车，等待上传完成100%。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/aba08998c63e6731a35892daa51511a042b5510b55dccefc120db355c6e5244e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、复制上一步红框内的网址，即为我们此次任务构建的前端网址。</p><p>4，差点忘了还有一个小步骤，部署的合约需要验证。</p><p>打开packages/hardhat/package.json将api修改为7C1S3PXQSGCERT5PJ67XR7TH74X2AH9ZR6（这玩意是我注册申请的，你想用自己的api去<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/register">Etherscan</a> 自己注册申请很简单，我不想教你们这种基础性操作了。）</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/84618d415cd352e9df656bd4ebec540f95bdc2122191bc1cfdc3f308640e3b71.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>在Terminal控制台输入yarn verify --network goerli坐等合约验证完成。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1a33821b37e036759064d6bd2ac87f005d92c5142791f3477118e35c9a5e3049.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">五、递交任务审核</h3><p>再次重申：这玩意有点看运气同样的代码操作有时候能过有时候不能过，┓( ´∀` )┏</p><p>2/3框内注意格式啊，最后点submint，好了本次发射已经完成，贤者时间了。</p><p>2框=教程第四大步第2小步获取的网址，3框=教程第三大步第2小步获取的合约地址前面加上goerli浏览器网址。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/576485e10b3f2a4b6744a808bcf9479a8984a5afb0814b164501362f50e43f92.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/fe373f46996cd95a880d0688e64d2ccf7157860a1693fa47dcc01dd3143d37f7.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Condor System 任务7：Advance Dapp]]></title>
            <link>https://paragraph.com/@doger/condor-system-7-advance-dapp</link>
            <guid>RgahhGgHjPmpWD8JJdUR</guid>
            <pubDate>Thu, 06 Oct 2022 09:59:25 GMT</pubDate>
            <description><![CDATA[我的推特：LiCrazy TL;DR:在任务3的基础上将dapp部署在condor网络上，难度不大，添加condor网络代码（代码库中已封装）后其他步骤类似任务3。一、克隆代码并在gitpod打开这一步很多人可能会打开不了代码库，初始化失败，原因就是gitpod跟github没有关联，应该用GitHub账号先去登陆gitpod。这应该是最基础的逻辑，你要在gitpod里面打开github的代码库，肯定要先让两个账号关联起来！！！！ 1、复制该代码库网址https://github.com/mesahin001/scaffold-eth 到gitpod直接开启new workspace。注：此代码库为discord社区成员已经添加过condor网络的代码，省去了任务中需要自行添加condor网络代码的步骤。二、在condor上部署合约1、打开packages/hardhat/hardhat.config.js文件，将defaultNetwork更改为“condor”。2、在下方TERMINAL控制台输入yarn generate创建一个地址。第二个红框内的地址即为创建的新钱包地址，...]]></description>
            <content:encoded><![CDATA[<p>我的推特：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://:https//twitter.com/0xFeng">LiCrazy</a></p><p>TL;DR:在任务3的基础上将dapp部署在condor网络上，难度不大，添加condor网络代码（代码库中已封装）后其他步骤类似任务3。</p><h3 id="h-gitpod" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">一、克隆代码并在gitpod打开</h3><p>这一步很多人可能会打开不了代码库，初始化失败，原因就是gitpod跟github没有关联，应该用GitHub账号先去登陆<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://gitpod.io/workspaces">gitpod</a>。这应该是最基础的逻辑，你要在gitpod里面打开github的代码库，肯定要先让两个账号关联起来！！！！</p><p>1、复制该代码库网址<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/mesahin001/scaffold-eth%EF%BC%89">https://github.com/mesahin001/scaffold-eth</a> 到<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://gitpod.io/workspaces">gitpod</a>直接开启new workspace。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/dbf7e3270828c7ee6e5943816c4d33a6b0810cf78ec282ce199c699af096d921.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e0893bd16b8d38b1a34fdb0181a93d2d2ba02157adf5c1f4e94327227c120f4a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9b7c2ff57565ceada1207a4c374c75bac8efdcb332066c1e079b68f7fb3b5f7c.png" alt="注：此代码库为discord社区成员已经添加过condor网络的代码，省去了任务中需要自行添加condor网络代码的步骤。" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">注：此代码库为discord社区成员已经添加过condor网络的代码，省去了任务中需要自行添加condor网络代码的步骤。</figcaption></figure><h3 id="h-condor" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">二、在condor上部署合约</h3><p>1、打开packages/hardhat/hardhat.config.js文件，将defaultNetwork更改为“condor”。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/51462b30470ecb22b5654d26be0e2f537e63589eddb9004682c44a6ba55c2a1b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、在下方TERMINAL控制台输入yarn generate创建一个地址。<strong>第二个红框内的地址即为创建的新钱包地址，转账一点conder进去作为gas。（特别注意仔细理解这句话⚠️⚠️⚠️）</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9ea967ca42f563a514bf6d078ac18f0b5be1d58c545bee2d5cfc88067c7d651d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、打开packages/hardhat/contracts下的YourContract.sol修改代码，我这里是改成了“all in web3”，你们随意。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/675a5c9db390598a651ae01a0a85e377ab591f977ca0c859b58bd51730b5235b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、在Terminal控制台输入yarn run deploy部署合约代码,红框2为我们部署的合约。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/47808480c2a4962ce9657d0b1cabcfd7a35cbc3b3dde70a8c04e60faf5257b94.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">三、部署前端</h3><p>1、打开packages/react-app/src文件夹下的App.jsx，将targetNetwork修改成NETWORKS.condor。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/26d8bfdc188206acb8eb518b210d2fb793a11759d9fd39439273a480340c057a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、在Terminal控制台输入yarn build,创建前端，需要等待较长的时间，如下图显示即为成功。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0afba188b849ffbbdb4d57211addd9867a9635ecf1cdd8fc726843550adc96f5.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、在Terminal控制台输入yarn surge，期间让会让你输入邮箱/密码创建surge账号，输入后每次回车即可。当出现domaim网址后再次回车，等待上传完成100%。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7da487cde088d42dcd0f586862a8863936fb56383da32c5f696e9e7604aa2e14.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、复制上一步红框内的网址，即为我们此次任务构建的前端dapp。然后在浏览器中打开,连接任意小狐狸钱包并切换到<strong>condor链</strong>进行交互。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2714fb7266a973c8dbe8c55286c34a10f2a56b22acb8000c7a9eef02ec982d1a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>最后如下图一所示即代表成功，将第三大步第4小步中点击“debugcontracts”获取的网页地址提交到相关discord频道即可，格式如图二。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/14c302fd8ec980b71c160cff852e1caf59dfb004140064c2cb7a143361db2deb.png" alt="图一：成功图示" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">图一：成功图示</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e16544bde2fbb3971fffa86b86296de209e4d39f4fa91424c59a2afd723b1448.png" alt="图二：任务提交网址格式" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">图二：任务提交网址格式</figcaption></figure>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/dfdc1a818e71eb94a9a03daad361cc27396f6a6845f231dd0ea7e2962ab7a0c8.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Condor Systems 任务3:部署Mint NFT的前端网页 ]]></title>
            <link>https://paragraph.com/@doger/condor-systems-3-mint-nft</link>
            <guid>ci8vmQm9wxd2PAWotjUM</guid>
            <pubDate>Thu, 06 Oct 2022 06:46:43 GMT</pubDate>
            <description><![CDATA[我的推特：LiCrazy TL;DR:遵照官方文档提示，在gitpod上面创建一个mint前端网页，在gitpod编译可以避免环境问题以及无需下载本地软件。 任务需求：创建一个nft合约以及mint的前端网页。【官方文档】 步骤：在gitpod打开代码/部署nft/部署前端/提交任务，主要内容是三、四步。一、用GitHub账户打开官方源码1、在gitpod打开官方源码:直接点击官方文档中的下方按钮，然后在弹出的对话框选择“continue with GitHub”登陆上你的github账号就行，再选择“new workspace”，等待一会最终如图四。这里可能根据每个人的账号设置略有差异，反正自己摸索一下：主旨就是用GitHub打开官方的这部分代码。图四：最终打开界面二、试用官方本地钱包（这部分其实做不做无所谓就是在钱包界面随意试用下）如下所示，先领水——>再转账——>再mint几次，随意点点吧。三、在goerli上部署nft合约1、刚才我们都是在本地钱包试用，接下来我们把它部署在goerli测试网上。 打开packages/hardhat/hardhat.config.js文件...]]></description>
            <content:encoded><![CDATA[<p>我的推特：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://xn--https-ni33a://twitter.com/0xFeng">LiCrazy</a></p><p>TL;DR:遵照官方文档提示，在gitpod上面创建一个mint前端网页，在gitpod编译可以避免环境问题以及无需下载本地软件。</p><p>任务需求：创建一个nft合约以及mint的前端网页。【<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://speedrunethereum.com/challenge/simple-nft-example">官方文档</a>】</p><p>步骤：在gitpod打开代码/部署nft/部署前端/提交任务，主要内容是三、四步。</p><h3 id="h-github" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">一、用GitHub账户打开官方源码</h3><p>1、在gitpod打开官方源码:直接点击官方文档中的下方按钮，然后在弹出的对话框选择“continue with GitHub”<strong>登陆上你的github账号就行</strong>，<strong>再选择</strong>“new workspace”，等待一会最终如图四。这里可能根据每个人的账号设置略有差异，反正自己摸索一下：主旨就是用GitHub打开官方的这部分代码。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/68721e3ea52cb7aab9604be489baf52f49173e8f3b9e0d53ea833d804b666ce9.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/81d241c5b9d0316a9589d367a1e2a2526e69c20ce59e7f4d09cc00c4984068ce.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c9a221cee5211621f385bc7f5ad7fb79cafa5afea0cbc670a499ca2fc49e15fd.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/23e6b91bfb510208d7ef311d5c4133c423b3baeb67748ca8b41cb0bc4fb708dc.png" alt="图四：最终打开界面" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">图四：最终打开界面</figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">二、试用官方本地钱包（这部分其实做不做无所谓就是在钱包界面随意试用下）</h3><p>如下所示，先领水——&gt;再转账——&gt;再mint几次，随意点点吧。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5f6d1f370924ac173ea5c9065345aabb89f4892360d53729f274509cd0baeb2c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/50b458d942f39fc9d11df34a6a6dcd26fddbdd3e0ea0abea9a40c0991b2051ab.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4bf4450430d0b48575a1bf688dbc1a86ad66421ecc32911432dca2aa987ce04e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-goerlinft" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">三、在goerli上部署nft合约</h3><p>1、刚才我们都是在本地钱包试用，接下来我们把它部署在goerli测试网上。</p><p>打开packages/hardhat/hardhat.config.js文件，将defaultNetwork更改为“goerli”。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/050a2444b76f00be15756b266c8d8e4f319c2f3791d7439ab3f185701e425c60.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、在下方TERMINAL控制台输入yarn generate创建一个地址。<strong>第二个红框内的地址即为创建新钱包地址，将此地址复制保存⚠️⚠️⚠️</strong>。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/960c9671bfe048ee329803eb7b24cdfbc591b94fe58f4a945bdf93ff49b6f324.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、去 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://faucet.paradigm.xyz/">https://faucet.paradigm.xyz/</a> <strong>给上一步创建的新地址领取一点点goerli网络上的eth作为gas（⚠️⚠️⚠️仔细看这句话的意思）</strong>，需要发推验证。当然不一定非得去这里领，只要你能搞到GoerliETH就行。</p><p>4、在Terminal控制台输入yarn deploy部署一个nft合约。红框2即为创建的nft合约地址，<strong>保存下来后面提交任务要用到</strong>。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/8b23da63d7d51aadc51d85a911f00772525edd6ce913f4d59999b02462476a80.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-mint" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">四、创建mint前端网页</h3><p>1、打开packages/react-app/src文件夹下的App.jsx，将targetNetwork修改成NETWORKS.goerli。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2c5165452f842bf6a6850e468c35af3e41c3db0db7348a5f65db2e505eeb4d91.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、点击右上角重新打开一个网页，会发现已经切换到goerli网。点击“connect”连接小狐狸钱包（注意将钱包切换到goerli，且有eth），然后点击“mint nft”交互一次。（<strong>这一步只是验证，其实不做也无所谓</strong>）</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d566230e9307f1429a38c16039719d2f81e4154f536ad8a22bc728eb4766c8b4.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/49332ca51a3d8a039de1ec06e69c08d3cc6ea14c6ce08102a2c51d0d0e3e691a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、在Terminal控制台输入yarn build,创建前端，需要等待较长的时间，如下图显示即为成功。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e256d57d76cfc86d59456df421d9402d0da43ebaf298b90c7826d7c57c765db1.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、在Terminal控制台输入yarn surge，期间让会让你输入邮箱/密码创建surge账号，输入后每次回车即可。当出现domaim网址后再次回车，等待上传完成100%。</p><p><strong>（⚠️注意：这一步可能会多次失败，不用怕重复运行yarn surge即可！！！）</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c10bab2d106db40bb46798c0a363d9c2618826a7fc1ec628b2e16e61b1d806ef.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>5、复制上图红框内的网址在浏览器打开，可以随意连接一个钱包在goerli测试网上mint，能成功mint则代表所有部署完成。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/07287d9d9b10a1a99285f61c93ef57360ebcd014b6c420cb959fad04d1076a10.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">五、任务确认以及提交</h3><p>1.还记得文首的官方文档不？打开官方文档，连接钱包，点击submit，在任务平台确认任务。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7844adf865a7942d225c8b077283b68968c7909562321010f2240a0da9295a04.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/40448b3301c88882d7a1f2acf4ba70765cf1cc01e29db67b429bfafb9f9ea8aa.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>红框1填入：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://polite-wine.surge.sh/">http://polite-wine.surge.sh/</a> 见教程第四大步第4小步。</p><p>红框2填入：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerli.etherscan.io/address/0x2Cc170B6d9916c0ed2b28f24B7954f11d81F73ab">https://goerli.etherscan.io/address/0x2Cc170B6d9916c0ed2b28f24B7954f11d81F73ab</a> 见教程第三大步第4小步。</p><p>2、在discord递交任务</p><p>将上一步红框1、2内的链接以及你的speedrun etheruem个人地址提交到相应的任务频道即可。</p><p>speedrun地址见下方红框。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a06fbac5b5fc3afab02c8dc108e93ea31fe24aa557773850d53fdbc2d653f798.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/dfdc1a818e71eb94a9a03daad361cc27396f6a6845f231dd0ea7e2962ab7a0c8.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[使用CID数据在zkSync二层Mint NFT]]></title>
            <link>https://paragraph.com/@doger/cid-zksync-mint-nft</link>
            <guid>rliz7lZjZCvBdOMesnoz</guid>
            <pubDate>Tue, 06 Sep 2022 05:05:58 GMT</pubDate>
            <description><![CDATA[TL;DR：通过ETH浏览器查询NFT合约的元数据地址，获取CID，然后MINT NFT。一、契机在使用zksync的时候是否有注意到钱包账户中的“+MINT NFT”按钮？理论上我们是可以在zksync上mint nft的，但是我们却很少看到zksync上的nft的项目。 点击进去我们看到其实是可以通过CID或者0xhash来mint的，那么我们怎么找到CID并mint呢？二、查找现有NFT项目CID1、我们以红豆(Azuki)为例，我们通过Opensea搜索找到Azuki项目，并随意点击其中一张NFT的“Details”找到其合约地址（也可以其他方式找到合约地址，方法很多并不唯一）。 2、在Ethscan搜索上一步找到的合约地址，并点击“Contract”--“Read Contract”，找到“Token url”点开，并随意输入一个数（当然这个数不能大于该nft的最大数量，比如azuki就是最多10k ），然后点“Query”会得到一个字符串，复制下图红框4里面的那串字符，这是azuki项目的元数据地址。当然有些项目“Query”后会发现并不是跟上面的一样，比如MAYC。...]]></description>
            <content:encoded><![CDATA[<p>TL;DR：通过ETH浏览器查询NFT合约的元数据地址，获取CID，然后MINT NFT。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">一、契机</h3><p>在使用zksync的时候是否有注意到钱包账户中的“<strong>+MINT NFT</strong>”按钮？理论上我们是可以在zksync上mint nft的，但是我们却很少看到zksync上的nft的项目。</p><p>点击进去我们看到其实是可以通过<strong>CID</strong>或者0xhash来mint的，那么我们怎么找到<strong>CID</strong>并mint呢？</p><h3 id="h-nftcid" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">二、查找现有NFT项目CID</h3><p>1、我们以红豆(Azuki)为例，我们通过<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://opensea.io/">Opensea</a>搜索找到Azuki项目，并随意点击其中一张NFT的“<strong>Details</strong>”找到其合约地址（也可以其他方式找到合约地址，方法很多并不唯一）。</p><p>2、在<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/">Ethscan</a>搜索上一步找到的合约地址，并点击“<strong>Contract</strong>”--“<strong>Read Contract</strong>”，找到“<strong>Token url</strong>”点开，并随意输入一个数（当然这个数不能大于该nft的最大数量，比如azuki就是最多10k ），然后点“<strong>Query</strong>”会得到一个字符串，复制下图红框4里面的那串字符，这是azuki项目的元数据地址。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/94725f69c9ab6ccc9671b21bcb2dfd3ba2090904a8a979d47e383bba4cce6a02.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ed550bd03f95c1034e63c02e74032fc742c9949a9ce6a3d612cc64b9f4bd4433.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>当然有些项目“<strong>Query</strong>”后会发现并不是跟上面的一样，比如<strong>MAYC</strong>。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/74fb74e9d065d3688a5c6d747a5fc26ee9af0da290dab64cbc80cb9fc9e48712.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>我们打开这个网址也会发现编号为4677的<strong>MAYC</strong>的<strong>CID</strong>数据，可以通过更改最后的编号获取对应的CID数据。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5df7df3c9991d9703083ef961823419df7ab1b4b440dba6e8739cb9c2d861a36.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>从这里可知：如果字段前面是非IPFS则说明该NFT项目数据保存在中心化网站，那就没必要继续下面的操作。</p><p>3、打开<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW">https://ipfs.io/<strong>ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW</strong></a>(加粗的字段就是2步查询获得的字符串,根据每个项目不同可以替换）。</p><p>如下图所示红框内即为每个编号所对应的CID，你想mint哪个编号就点哪个。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d0ee8c1726020d680175fa421cd8adaad5be420a2b39da8f13056b3dccef9d3a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、然后你会发现无法复制，点开该CID，在弹出的网址中复制下图所示红框中的内容。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/393cfdd83a151ce544367d9772a3dfd43ec097bd8d20116822da0fa432443d3f.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-mint-nft" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">三、MINT NFT</h3><p>将上一步复制的CID，粘贴Meatamask钱包在<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wallet.zksync.io/transaction/nft/mint">zksync</a>网络上账户，点击**“MINT”**即可，成功后可在账户里看到token。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/401518344b7ed8d936994dabcaefc1d21d2de7ae891004ee19380cc1cf7d5582.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/29b9998ac8612537217ec696138cb84a6bac21c0a5ca074b51d3f56bb4996e1e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">四、注意</h3><p>1、该操作只是mint了Azuki在zksync上的小图片，可以看做是一个山寨，不具备真正价值。操作的意义在于丰富zksync的链上数据，且gas极低。</p><p>2、只有是在IPFS上传元数据的项目才会有<strong>CID</strong>数据，有些古早项目比如<strong>punk</strong>是保存在中心化网站上，此操作行不通。</p><p>3、如果想mint其他项目的nft也可以自己去发掘获得CID数据就可mint。</p><p>4、“<strong>TokenURL</strong>”那一步获取的网址大家可以大胆试错，小心求证，每个项目方的保存方式/格式可能不一样，多试试就知道看是不是我们需要的<strong>CID</strong>。</p><p>5、下方是一些可以通过该方法mint的著名项目(注：有些需自己更改编号，不要一窝蜂mint相同编号)</p><p><strong>MAYC</strong>:<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://boredapeyachtclub.com/api/mutants/2732">https://boredapeyachtclub.com/api/mutants/2732</a> (注意修改链接最后编号)</p><p><strong>AZUKI</strong>:<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW">https://ipfs.io/ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW</a></p><p><strong>BAKC</strong>:<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmTDcCdt3yb6mZitzWBmQr65AW6Wska295Dg9nbEYpSUDR">https://ipfs.io/ipfs/QmTDcCdt3yb6mZitzWBmQr65AW6Wska295Dg9nbEYpSUDR</a></p><p><strong>BAYC</strong>:<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq">https://ipfs.io/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq</a></p><p><strong>Invisible Friends:</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmarGRwVKPaCe2s5QSSTMEdbYDwKxFz6bAn58YZPPcWc7k">https://ipfs.io/ipfs/QmarGRwVKPaCe2s5QSSTMEdbYDwKxFz6bAn58YZPPcWc7k</a></p><p><strong>Mfers：</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmWiQE65tmpYzcokCheQmng2DCM33DEhjXcPB6PanwpAZo">https://ipfs.io/ipfs/QmWiQE65tmpYzcokCheQmng2DCM33DEhjXcPB6PanwpAZo</a></p><p><strong>JENNIE HUMAN:</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmeAH1Cxrmo9bMmsJZ4oM774BHxW4dkY1RacjdZ3S5GZ5j">https://ipfs.io/ipfs/QmeAH1Cxrmo9bMmsJZ4oM774BHxW4dkY1RacjdZ3S5GZ5j</a></p><p><strong>Nyolings：</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmPXXVR4iDXnEt4hiXUZEuAxNNyd7qRWfPwCDtKiAij3um/4970.json">https://ipfs.io/ipfs/QmPXXVR4iDXnEt4hiXUZEuAxNNyd7qRWfPwCDtKiAij3um/</a></p><p><strong>Goblintown:</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmdxDAXQZn7LtbTCrfLgYX2YbWHGi2t7UQwqSEpt45YEh2/">https://ipfs.io/ipfs/QmdxDAXQZn7LtbTCrfLgYX2YbWHGi2t7UQwqSEpt45YEh2/</a></p><p><strong>Beanz</strong> :<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ipfs.io/ipfs/QmTRuWHr7bpqscUWFmhXndzf5AdQqkekhqwgbyJCqKMHrL/">https://ipfs.io/ipfs/QmTRuWHr7bpqscUWFmhXndzf5AdQqkekhqwgbyJCqKMHrL/</a></p>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/f63cce834a31036a0a6d0bc3476959f43fffdde5bf896131440f81cbc0046932.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Alchemy Road to Web3第八周:部署一个随机数合约]]></title>
            <link>https://paragraph.com/@doger/alchemy-road-to-web3-2</link>
            <guid>CzdgfWJC5N9WNur6dDwe</guid>
            <pubDate>Tue, 30 Aug 2022 04:06:25 GMT</pubDate>
            <description><![CDATA[TL;DR:本周任务是在ETH goerli测试网上做的，并非官方的Optimism网络。本文一共包括：准备/环境搭建/合约部署/交互/发布与提交。 该周任务相对简单：从官方fork代码后只需修改一次代码，然后执行几次命令即可完成。第一步、准备1、进入https://github.com/qbzzt/qbzzt.github.io/tree/master/LogRocket/20220615-random，点击Fork，把代码复制到我们的Github。2、进入到我们的replit.com账号，点击“create”---“Import from Github”，然后选择我们上一步fork的代码库:magweek8(你的名字可能不同，看你自己上一步命名的是什么)，再次点击“Import from Github”导入代码，导入时间可能要几分钟。 （注意：此步骤的前提是已经将replit账号与github账号关联，如何关联请查阅前序）3、导入成功后点击“done”第二步、环境搭建1、在右侧命令栏“shell”下输入cd LogRocket/20220615-random并回车进入2022...]]></description>
            <content:encoded><![CDATA[<p>TL;DR:本周任务是在ETH goerli测试网上做的，并非官方的Optimism网络。本文一共包括：准备/环境搭建/合约部署/交互/发布与提交。</p><p>该周任务相对简单：从官方fork代码后只需修改一次代码，然后执行几次命令即可完成。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第一步、准备</h3><p>1、进入<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/qbzzt/qbzzt.github.io/tree/master/LogRocket/20220615-random">https://github.com/qbzzt/qbzzt.github.io/tree/master/LogRocket/20220615-random</a>，点击Fork，把代码复制到我们的Github。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/37af5ef0990d4197ac39bdf001d43bb0188af14cfa290c06a272820b119f38b3.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/563ddfd2612ae9791a8b252f7342de7cad8bfdb58a76628c4870bb50ec01aeae.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、进入到我们的replit.com账号，点击“<strong>create</strong>”---“<strong>Import from Github</strong>”，然后选择我们上一步fork的代码库:magweek8(你的名字可能不同，看你自己上一步命名的是什么)，再次点击“<strong>Import from Github</strong>”导入代码，导入时间可能要几分钟。</p><p><strong>（注意：此步骤的前提是已经将replit账号与github账号关联，如何关联请查阅</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E"><strong>前序</strong></a><strong>）</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/24c23be33f572a01a56e40de2bdf2151712cfd8738e8f81aba2de3568cb15a8f.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/bfe41d782136e41d9d003c261c6b98b1d4a7176e30e5dbc7d2eb4c019d8afa7d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、导入成功后点击“<strong>done</strong>”</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/371514a27a2cb8691814a6508301f987a173272df1b28f636a4dd9c6580ebb56.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第二步、环境搭建</h3><p>1、在右侧命令栏“<strong>shell</strong>”下输入cd LogRocket/20220615-random并回车进入20220615—random子目录。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/95e2b2b2b70fb58e824cf060f30b769a963e598c72d37a3ac2ac3991d220d6da.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、继续输入npm i并回车，等待安装完成，需要几分钟。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b01b716ff3d95f6de9b3cd882eded0776dc4f4b00b258b72f79a8bdf9efb8f62.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、找到hardhat.config.js文件，将原文替换为以下代码。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/68da0ed038f6f25476b19cf8850ba9d7a30e3ad433e92207b33cd27d2f25553d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>require(&quot;@nomiclabs/hardhat-waffle&quot;); require(&apos;dotenv&apos;).config()</p><p>// This is a sample Hardhat task. To learn how to create your own go to // <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://hardhat.org/guides/create-task.html">https://hardhat.org/guides/create-task.html</a> task(&quot;accounts&quot;, &quot;Prints the list of accounts&quot;, async (taskArgs, hre) =&gt; { const accounts = await hre.ethers.getSigners();</p><p>for (const account of accounts) { console.log(account.address); } });</p><p>module.exports = { solidity: &quot;0.8.4&quot;,</p><p>networks: { &quot;goerli&quot;: { url: &quot;alchemy账号里 Goerli url &quot;, accounts: [&quot;{你的metamask钱包私钥}&quot;] } }</p><p>};</p><p>其中{你的metamask钱包私钥}需要替换为你自己的私钥，<strong>私钥用完记得删除</strong>，建议新建小号。alchemy账号里 Optimism Goerli url替换为你在alchemy里创建的Optimism Goerli API 的https。（<strong>注意：该两个字段的双引号不可删除，如何创建API请查阅</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E"><strong>前序</strong></a>）</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第三步、部署合约</h3><p>1、因为咱们所有的部署执行都是链上行为，需要用到gas，我们先去领点EHT测试币。</p><p>登陆<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerlifaucet.com/">https://goerlifaucet.com/</a> 账号输入钱包地址点击“Send me ETH”领取EHT goerli测试网上的ETH</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7d520a3a7968a47762bbe62bb9e925c6d983e104e902647feaa511684179522e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>将钱包切换到ETH georli网（如何添加georli请去<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://chainlist.info">https://chainlist.info</a> 搜索eth找到goerli并添加到钱包）。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4651c2490aa8f6252c90170af066d8764ea983fceef4797ab803d67af6878274.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、在“<strong>shell</strong>”中输入yarn hardhat console --network goerli回车，中间可能可能需要一次回车。</p><p><strong>（注：此时可能你的shell中已经回到上一级目录，这时可以通过输入cd LogRocket/20220615-random重新进入子目录，以后遇到类似情况照此执行）</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/38e168e528446687e1950c286ecdc70ca57965b9a93ee47af8b3c65b5179af13.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>（注意：如果你想重新使用上面的命令（yarn hardhat console --network goerli）开始部署合约，记得把artifacts/cache这两个文件夹删掉）</strong></p><p>3、输入signer = await ethers.getSigner();并回车</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a507f7aba57a5f441ab4a5f9b4766df540a3468db0d926053041f098d9d98e90.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>输入balance0 = await ethers.provider.getBalance((await ethers.getSigner()).address)并回车。</p><p>输入factory = await ethers.getContractFactory(&quot;Casino&quot;)并回车。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/25234f38725bda50370de591b971f676a87706fed8724d27bf7ccd4e5265577c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>输入casino = await factory.deploy()并回车，至此已经完成合约部署，可以看到下方合约地址。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7e3fd3db1dcfd0ef607b9226f1d15c7db9be04a2fb1da7d12e3f2dcccffedc37.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第四步、合约交互</h3><p>输入const valA = ethers.utils.keccak256(0xBAD060A7)并回车</p><p>输入const hashA = ethers.utils.keccak256(valA)并回车</p><p>输入const valBwin = ethers.utils.keccak256(0x600D60A7)并回车</p><p>输入tx1 = await casino.proposeBet(hashA,{ value: 1e5})并回车</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/90d29a583d533ff836a6a569f118889661a2f206c79be58e77d3228f9bfebb73.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>等待上一步代码执行完毕后，输入tx2 = await casino.acceptBet(hashA, valBwin, {value: 1e5})并回车。</p><p>执行成功后去<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerli.etherscan.io/address/">https://goerli.etherscan.io/address/</a>搜索<strong>第三步第3点</strong>部署的合约地址，可以看到该合约地址会有三笔交互记录，代表任务成功。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1c3470a0aba551fa64b25a46e6a371f553075b8963e6c4f414605367efd9815c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>（注意：如果交互中出现错误或者无法执行下去，可以查看第三步第2点注意那里，删掉artifacts/cache这两个文件夹重新部署合约再进行交互）</strong></p><p><strong>第五步、发布提交</strong></p><p>1、replit上发布，点击“<strong>publish</strong>”然后一直点“<strong>next</strong>”即可。<strong>记得删掉私钥！！！</strong></p><p>复制好最后获得的项目网址。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d52d06d7ec1c7819192450c8f7f17a59099d195a139280fed0592d7ea43dd673.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9b47dd54442328c0b5f969bc8c204bfe18219dcc6e54fe2282c1eb96e2e3a521.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/8f448e7df11c63dd1053da6ed9c8a2554d0e1f2c7a0397cd26e73e2dccb87e52.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、同步更新到Github，去到github复制代码库地址。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e68c52d69026423dc3340827d08d57d7d26e740f1b575e811a1065b42419f595.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、提交：打开<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://forms.gle/Ztv2nLqsV158XEaeA">https://forms.gle/Ztv2nLqsV158XEaeA</a></p><p>①将第三步第3点获取的合约地址</p><p>②第五步第1点获取的项目网址</p><p>③第五步第2点你的Github代码库地址提交进去即可。</p>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/2615abfe7565e8490ab0a107b9058cff42461e67a20d0c864e83d23876a60641.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Alchemy Road to Web3第三周:铸造 NFT并刷新元数据]]></title>
            <link>https://paragraph.com/@doger/alchemy-road-to-web3-nft</link>
            <guid>Xiz08y9urbYYgbqtzGDQ</guid>
            <pubDate>Mon, 29 Aug 2022 10:03:16 GMT</pubDate>
            <description><![CDATA[TL;DR:这周教程也是一共包括六个步骤，目的是部署一个NFT合约，并与之进行交互，刷新元数据。主要内容包括：准备/搭建环境/代码编译/部署合约/合约交互/发布与提交。第一步、准备：1、结合之前前序文档，创建好本周的github代码库以及同步到replit.com上。 如图，依次点击右上角github账号--“repositories”--“new”--填写“name”（随意）--“create repository”(切记勾选“add a README file”不然会是一个空库，无法导入replit)2、登陆你的replit账号，依次点击“create”--“import”，然后选择上一步创建的代码库“magweek3”，再次点击“import from github”，完成代码的导入工作。 （注意在开始这一步之前，必须要先关联好github账号，如何关联请看之前前序）导入完成之后，点击“DONE”第二步、环境搭建1、回到replit左边栏，删除掉README.md。2、点击右侧“Shell”，创建ChainBattle目录并进入，输入mkdir ChainBattle并回车...]]></description>
            <content:encoded><![CDATA[<p>TL;DR:这周教程也是一共包括六个步骤，目的是部署一个NFT合约，并与之进行交互，刷新元数据。主要内容包括：准备/搭建环境/代码编译/部署合约/合约交互/发布与提交。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第一步、准备：</h3><p>1、结合<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">之前前序</a>文档，创建好本周的github代码库以及同步到replit.com上。</p><p>如图，依次点击右上角github账号--“repositories”--“new”--填写“name”（随意）--“create repository”<strong><em>(切记勾选“add a README file”不然会是一个空库，无法导入replit)</em></strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ebceb3f97fe943eb30a7240565bd9a87d95240d917e8375141a4ff6e258e8620.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/33d05c0e6c7439bdc8c4a4a816d813b5dbebe34bcd119300ff8da282b928b141.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、登陆你的<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://replit.com/">replit</a>账号，依次点击“create”--“import”，然后选择上一步创建的代码库“magweek3”，再次点击“import from github”，完成代码的导入工作。</p><p>（注意在开始这一步之前，必须要先关联好github账号，如何关联请看<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">之前前序</a>）</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/8ae1ed9088c2606267667ea811ac788ea31473d3fcf65edab4aaebadec39dffe.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2f0840c7b43c13a44f8437833366e8130bf452c357a1ebec8a8f717cc767d461.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>导入完成之后，点击“DONE”</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6d52ef579b044f48db22f87424fbdaf260bb81c87f80eb8a16bc712c6d970eb6.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第二步、环境搭建</h3><p>1、回到replit左边栏，删除掉README.md。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ba8aea5ec8c567447b62432e55ed360f51336a272fecbf643889e17e82368f31.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、点击右侧“Shell”，创建ChainBattle目录并进入，输入mkdir ChainBattle并回车，然后输入cd ChainBattle并回车。<strong>（以下步骤的命令都是在“shell”中输入）</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d09f23b6c8f2291d7f565df72d9af1acf50975a3805bc814f89a074124877f1b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、输入npm init -y并回车（中间可能会要再次回车一次）。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/84dbb5fa0b941a1596d4d00de833db6884c420514df8e08d4990c1659bc9097d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、输入npm install hardhat并回车，等待安装完成，如下图所示。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c5393055f7fdaf9fe26b83a1b937f3f6319b784bff41b9d4dcb8db62b6cdb7ee.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、输入npx hardhat init并回车,（中间应该需要点5次回车，多点几次也无妨😆，warn不用管）等待安装完成，如下图所示。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c7d13758da61103f2e4ed7a2ccf150d2869777569d97bb83764b18fa9ae4a4cd.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/91f7e6ceff6844365f0508930e54c829fb988bebea1e51a1adef6b0e9fa1a859.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>5、输入npm install @openzeppelin/contracts并回车，等待安装完成，如下图。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/02673251fab7a2fc5ba7c47e8eccd6d5ecae6bb012c40b5ada88be352a999493.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>6、输入npm install @nomiclabs/hardhat-etherscan并回车，等待安装完成，如下图。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/161573f0c1399cc952d8d3c1e4ad2a9ddbaed7a792e0bf50cf156a894854bd4f.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>7、输入npm install @nomiclabs/hardhat-waffle并回车，等待安装完成，如下图。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d599dbcc390d56a19aa8183d853df331f5a7820c13e83db57c2a6036adbeaef4.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>8、输入npm install dotenv并回车，等待安装完成，如下图。</p><p><strong>至此所有环境搭建已经完成，中途应该不会遇到本地环境兼容问题</strong>🏂，这就是网页端搭建的好处。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3e5bf21d4cbf596ee58bca754078c7df26e3a7d6fd40c2f717fc3a0fbb0c3921.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第三步、代码编译</h3><p>1、打开contracts目录，把Lock.sol重命名为ChainBattles.sol。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c095c7015048315912b7bcf3d6b2580297f0f3018d18a34978c4ddb1dc99e784.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、将上一步重命名为ChainBattles.sol的文件里的内容替换为以下代码。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/479da0f8c358e6ee235d8f00066e58c71eeee159c48176d4739c528efc679eaa.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>// SPDX-License-Identifier: MIT pragma solidity ^0.8.0;</p><p>import &quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol&quot;; import &quot;@openzeppelin/contracts/utils/Counters.sol&quot;; import &quot;@openzeppelin/contracts/utils/Strings.sol&quot;; import &quot;@openzeppelin/contracts/utils/Base64.sol&quot;;</p><p>contract ChainBattles is ERC721URIStorage { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIds;</p><pre data-type="codeBlock" text="mapping(uint256 =&gt; uint256) public tokenIdToLevels;

constructor() ERC721 (&quot;Chain Battles&quot;, &quot;CBTLS&quot;){
}
"><code><span class="hljs-keyword">mapping</span>(<span class="hljs-keyword">uint256</span> <span class="hljs-operator">=</span><span class="hljs-operator">></span> <span class="hljs-keyword">uint256</span>) <span class="hljs-keyword">public</span> tokenIdToLevels;

<span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title">ERC721</span> (<span class="hljs-params"><span class="hljs-string">"Chain Battles"</span>, <span class="hljs-string">"CBTLS"</span></span>)</span>{
}
</code></pre><p>function generateCharacter(uint256 tokenId) public returns(string memory){</p><pre data-type="codeBlock" text="bytes memory svg = abi.encodePacked(
    &apos;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; preserveAspectRatio=&quot;xMinYMin meet&quot; viewBox=&quot;0 0 350 350&quot;&gt;&apos;,
    &apos;&lt;style&gt;.base { fill: white; font-family: serif; font-size: 14px; }&lt;/style&gt;&apos;,
    &apos;&lt;rect width=&quot;100%&quot; height=&quot;100%&quot; fill=&quot;black&quot; /&gt;&apos;,
    &apos;&lt;text x=&quot;50%&quot; y=&quot;40%&quot; class=&quot;base&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot;&gt;&apos;,&quot;Warrior&quot;,&apos;&lt;/text&gt;&apos;,
    &apos;&lt;text x=&quot;50%&quot; y=&quot;50%&quot; class=&quot;base&quot; dominant-baseline=&quot;middle&quot; text-anchor=&quot;middle&quot;&gt;&apos;, &quot;Levels: &quot;,getLevels(tokenId),&apos;&lt;/text&gt;&apos;,
    &apos;&lt;/svg&gt;&apos;
);
return string(
    abi.encodePacked(
        &quot;data:image/svg+xml;base64,&quot;,
        Base64.encode(svg)
    )    
);
"><code><span class="hljs-keyword">bytes</span> <span class="hljs-keyword">memory</span> svg <span class="hljs-operator">=</span> <span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encodePacked</span>(
    <span class="hljs-string">'&#x3C;svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350">'</span>,
    <span class="hljs-string">'&#x3C;style>.base { fill: white; font-family: serif; font-size: 14px; }&#x3C;/style>'</span>,
    <span class="hljs-string">'&#x3C;rect width="100%" height="100%" fill="black" />'</span>,
    <span class="hljs-string">'&#x3C;text x="50%" y="40%" class="base" dominant-baseline="middle" text-anchor="middle">'</span>,<span class="hljs-string">"Warrior"</span>,<span class="hljs-string">'&#x3C;/text>'</span>,
    <span class="hljs-string">'&#x3C;text x="50%" y="50%" class="base" dominant-baseline="middle" text-anchor="middle">'</span>, <span class="hljs-string">"Levels: "</span>,getLevels(tokenId),<span class="hljs-string">'&#x3C;/text>'</span>,
    <span class="hljs-string">'&#x3C;/svg>'</span>
);
<span class="hljs-keyword">return</span> <span class="hljs-keyword">string</span>(
    <span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encodePacked</span>(
        <span class="hljs-string">"data:image/svg+xml;base64,"</span>,
        Base64.encode(svg)
    )    
);
</code></pre><p>} function getLevels(uint256 tokenId) public view returns (string memory) { uint256 levels = tokenIdToLevels[tokenId]; return levels.toString(); } function getTokenURI(uint256 tokenId) public returns (string memory){ bytes memory dataURI = abi.encodePacked( &apos;{&apos;, &apos;&quot;name&quot;: &quot;Chain Battles #&apos;, tokenId.toString(), &apos;&quot;,&apos;, &apos;&quot;description&quot;: &quot;Battles on chain&quot;,&apos;, &apos;&quot;image&quot;: &quot;&apos;, generateCharacter(tokenId), &apos;&quot;&apos;, &apos;}&apos; ); return string( abi.encodePacked( &quot;data:application/json;base64,&quot;, Base64.encode(dataURI) ) ); } function mint() public { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _safeMint(msg.sender, newItemId); tokenIdToLevels[newItemId] = 0; _setTokenURI(newItemId, getTokenURI(newItemId)); } function train(uint256 tokenId)public{ require(_exists(tokenId)); require(ownerOf(tokenId)==msg.sender,&quot;You must own this token to train it&quot;); uint256 currentLevel=tokenIdToLevels[tokenId]; tokenIdToLevels[tokenId]=currentLevel+1; _setTokenURI(tokenId,getTokenURI(tokenId)); } }</p><p>3、在ChainBattle文件夹下新建.env文件，并在该文件内输入以下代码。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d69cefeb9be398814c931a1b2003355417a223bd92c4cec45df862af8b148e43.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>TESTNET_RPC=</p><p>PRIVATE_KEY=</p><p>POLYGONSCAN_API_KEY=</p><p>4、在alchemy.com里面创建（如何创建详见:<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">之前前序</a>）一个Polygon Mumbai网络的APP，<strong>复制其URL粘贴到.env的TESTNET_RPC=后面</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/83a1f35533c89430576b6f3413528e8db14f56b017b807c7123afd3dea8a850a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>将metamask钱包的新建小号私钥导出（如何导出详见:<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">之前前序</a>），<strong>并复制粘贴到PRIVATE_KEY=后面。</strong></p><p>进入polygonscan.com，登陆你的账号（需要先注册这里不赘述）依次点击“API keys”-- “Add”创建一个API。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/45d2a45783dc8ae69aa080035bdd816b0240f5621c9b79227ce41e2a082d585b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>然后<strong>复制你刚才创建的那个API代码粘贴到POLYGONSCAN_API_KEY=后面</strong>，如下图红框内。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9ece1cea3f91427a77ee740aba9b1e001d27b792344da3f59194f32817a618ad.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>5、最后.env文件内的代码大概如下图所示。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/fac5e5e3dc8f2689589c16ceb4cf83f9236f1f14ab9ebe6197d3e6ddfdaee6c0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>6、打开hardhat.config.js文件，将一下代码粘贴进去，如图所示。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c5c94194b6d4eb644ac685bf3186fdae9bbb662ed7b2eb682ba100bc41a4f759.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>require(&quot;dotenv&quot;).config();</p><p>require(&quot;@nomiclabs/hardhat-waffle&quot;);</p><p>require(&quot;@nomiclabs/hardhat-etherscan&quot;);</p><p>module.exports = {</p><p>solidity: &quot;0.8.10&quot;,</p><p>networks: {</p><p>mumbai: {</p><p>url: process.env.TESTNET_RPC,</p><p>accounts: [process.env.PRIVATE_KEY]</p><p>},</p><p>},</p><p>etherscan: {</p><p>apiKey: process.env.POLYGONSCAN_API_KEY</p><p>}</p><p>};</p><p>7、代码编译已经完成，测试一下是否编译成功。在Shell那边输入npx hardhat compile并回车（中间大概需要5次回车🚒）。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9f5c3efa76b72fd9275e88cecbfa545e5823f13029d5529194adaac21746b887.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第四步、部署合约</h3><p>1、添加好mumbai测试网及领取测试币。</p><p>①进入<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://chainlist.info">chainlist.info</a>，搜索mumbai，将matic测试网添加到Metamask钱包。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/60583346a20365facc10ead5392e4728f19bef8b4359273b0239d8e410d35e6c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>②进入<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://xn--https-ep5h3448a://mumbaifaucet.com/">https://mumbaifaucet.com/</a>，右上角登陆Alchemy账号，粘贴钱包地址，点击“Send Me Matic”获取测试币。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2407db2e827beb46f5a7b7f6e75a975bf4bcb87882e423dd0d02dd4c36091046.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、然后回到Replit，打开scripts/deploy.js，将原文替换成以下代码。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/156ba42bf4a45068bcb638170a7be819412f02a0aafe506954286abc8c7c6c29.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>const main = async () =&gt; { try { const nftContractFactory = await hre.ethers.getContractFactory( &quot;ChainBattles&quot; ); const nftContract = await nftContractFactory.deploy(); await nftContract.deployed();</p><pre data-type="codeBlock" text="  console.log(&quot;Contract deployed to:&quot;, nftContract.address);
  process.exit(0);
} catch (error) {
  console.log(error);
  process.exit(1);
}
"><code>  console.log(<span class="hljs-string">"Contract deployed to:"</span>, nftContract.<span class="hljs-built_in">address</span>);
  process.exit(<span class="hljs-number">0</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
  console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  process.exit(<span class="hljs-number">1</span>);
}
</code></pre><p>};</p><p>main();</p><p>4、在Shell处输入npx hardhat run scripts/deploy.js --network mumbai并回车（中间可能会有一次回车）。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7cff8391c45fede21199a0731e7e8bf58882d26bfc703b85e8fe86e4c4f809f7.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>5、点击Metamask钱包三点处，然后点区块浏览器，然后弹出新新网页查看合约地址是否一致，并等待contract处是否出现✅。如若没有，则输入npx hardhat verify --network mumbai +你的合约地址，进行验证。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a748e18c5f8b22462e4088ff84b250e24be22827fa09688f189aa8d0bef5b04e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0a9652392a8417ed423a9aacb8912a6bf785aa094f3b2c9a040ddb63929d961a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9345399c86ec39127da338efc59374fc6a164affecae770f8d78633b536ef81e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>最终出现“successfully submit”则代表合约部署已经成功完成。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第五步、合约交互</h3><p>1、切换到之前打开的合约网页上，点开Contract--Write contract--connect to web3，在弹出的钱包中点确定，连接之前对应的私钥钱包。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d2563b21164226bc465c2e438f2e9eadb429693d1adf4f5b98b4479d5107af61.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、点击第4个“mint”下的write，在钱包中确认，等待交互成功。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4923cb37de751f127a196af26b8a2cdf110f02f7408349a5c3d8cb70d5ed129b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、前往 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://testnet.opensea.com">testnet.opensea.com</a> ，连接我们刚才的钱包，点击profile，找到我们刚才mint的nft，点进去会发现如下图所示。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4d18d7d1f4cadbc575f2fa4f991d946f3f4c8b4101fa44b5bc73e6700443bb21.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3a652f1f78da22e4d80efb1e1940eaf41270c404fce13947c611bd0324a359d2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、继续回到合约那边，选到第8个train，在框中输入1，点击write，弹出小狐狸，点确认等待链上确认成功。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2e7fb934bb41c50b4a7e1a218c94b68898ebf89839b3df63ff159570816cdd74.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>5、再次回到<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://testnet.opensea.com">testnet.opensea.com</a> 刷新网页，如下图所示，可以看到0变成1了，表示该任务已经成功完成。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1a14a41725d558e54a6406d1dcad2ee76cc5668f9db16951c8c946b94be1f269.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">第六步、发布与提交</h3><p>1、如图点击publish，填好description然后一直点下一步即可发布成功，保存好最后出来的那个网址，作为提交证明。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6552d84f18baaecec9241bfc0f72d2295e152fe80acda6090e46ad9d99b26712.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/41bdeab629fa2a010f0bd6a3b7926d06e4a08ec28cbfa90fb82c54148f62927d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、提交到github，提交之前记得删除.env（保险起见）。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5651fc15659b64ec9f2e6df790cd97755be141a0bd20a9c4b4f6d9db17b34d98.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>将代码提交到github，并在你的github账号查看提交记录，复制好你的github本周代码库网址（图二红框处）作为任务提交证明。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f251fc02df06bbaffeda8cc44c8c8312f7df7a47848a1bcf1cfbf06f633c42ed.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、任务提交<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://forms.gle/DdnKrEvKzUHK4yLH9">https://forms.gle/DdnKrEvKzUHK4yLH9</a></p><p>主要是三个链接：1第四步第4点部署到合约地址，2第六步第1点获取的published地址</p><p>3第六步第2点获取的github代码库地址。</p>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/bd72d6faf4cb2a46814c1ffc137bd9174878e12e69af6d14de39c208406d63fc.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Alchemy Road to Web3第二周部署买咖啡Dapp]]></title>
            <link>https://paragraph.com/@doger/alchemy-road-to-web3-dapp</link>
            <guid>pNeyARpRTqRBurWDkIrV</guid>
            <pubDate>Thu, 25 Aug 2022 08:19:31 GMT</pubDate>
            <description><![CDATA[TL;DR本文主要由六部分组成,分别为：准备、搭建环境、代码编译、代码测试、部署Dapp、发布与提交。一、准备：1、结合之前前序文档，创建好本周的github代码库以及同步到replit.com上。 如图，依次点击右上角github账号--“repositories”--填写“name”（随意）--“create repository”(切记勾选“add a README file”不然会是一个空库，无法导入replit)2、登陆你的replit账号，依次点击“create”--“import”，然后选择上一步创建的代码库“magweek2”，再次点击“import from github”，完成代码的导入工作3、进去项目后，如下图所示，点击“Done”二、搭建环境1、点击右边“Shell”，首先输入mkdir BuyABCACoffee-contracts并回车（ABC3个字母处，可改为任意名字，后文涉及到ABC处的均可替换为自己定义的名字，也可以不改~）； 再次输入cd BuyABCACoffee-contracts并回车。2、输入npm init -y并回车。3、输入npx...]]></description>
            <content:encoded><![CDATA[<h3 id="h-tldr" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">TL;DR</h3><p>本文主要由六部分组成,分别为：准备、搭建环境、代码编译、代码测试、部署Dapp、发布与提交。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">一、准备：</h3><p>1、结合<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">之前前序</a>文档，创建好本周的github代码库以及同步到replit.com上。</p><p>如图，依次点击右上角github账号--“repositories”--填写“name”（随意）--“create repository”<strong><em>(切记勾选“add a README file”不然会是一个空库，无法导入replit)</em></strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4a2f9045e5922de5fb99319fe2728d1496155af2ef2ce2f27901e77da304e4c0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e291aca4c78c9fc0c043df159d84ef34bc929fa0eb4f1c5f85f18d467e267a93.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、登陆你的<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://replit.com/">replit</a>账号，依次点击“create”--“import”，然后选择上一步创建的代码库“magweek2”，再次点击“import from github”，完成代码的导入工作</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ef7290fc73a4b1267e7bc9a67082aacb2dab7521e623adddee543f98ed1ad205.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2dd1d734cbc55284aeaff5215f4349e828d2827af6f1423c01740e3e0bd914a5.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、进去项目后，如下图所示，点击“Done”</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/fb43a694c2c6533a91035f7e56817134d3014ca87273c898093a5d5c8ac30d3b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">二、搭建环境</h3><p>1、点击右边“Shell”，首先输入mkdir BuyABCACoffee-contracts并回车（ABC3个字母处，可改为任意名字，后文涉及到ABC处的均可替换为自己定义的名字，也可以不改~）；</p><p>再次输入cd BuyABCACoffee-contracts并回车。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/dac565e6a333d69c42cde06a17a66d8296655b23e6642d731ef5820e64b9164e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、输入npm init -y并回车。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5b8b4406e4c92a13820441e45526efc5ebb530d113d96bf660294f72a7df63d6.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、输入npx hardhat并回车。(中间大约需要点5次回车，就是那几个√的地方需要按回车才能继续）</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5d80199f6b2d741d93e77aa9891728c7db24e80cd063c1c49d5af6a776b02a2c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>大概成功安装后会如下图所示：</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/bb1cb259fd0b1199aaf5df0b3b9debc18aee8db57c824f47584aa6396f769159.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、输入npm install --save-dev @nomiclabs/hardhat-waffle 并回车，等待安装完成。（中间各种warn不要管）</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/28e917ce39d8c6a809f77c90a8ed183003521c03b3f5555bc72133a22d9991ae.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>5、输入npm install dotenv并回车，等待安装完成。<strong><em>至此环境搭建步骤已经完成。</em></strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6f016c21ddff94f6c9cedf373ee32e0f6c110fec6b8edbd3437db696d800c566.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">三、项目代码编译</h3><p>1、点开contracts目录，把Lock.sol重命名（rename）为<strong>BuyABCACoffee.sol</strong>(注意，文件名最好与前面创建的目录前缀一致)</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3bac0a6243f0b8ac950b0abe43b0f5760868a1851609e2a4c310be46bf6ceeb3.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2、点击刚才改名的“<strong>BuyABCACoffee</strong>”文件，将里面的内容替换为如下代码：</p><p><strong><em>（特别注意ABC可以改成自己设置的名字，需与前面保持一致。 记得保存文件内容）</em></strong></p><p>// SPDX-License-Identifier: UNLICENSED</p><p>pragma solidity ^0.8.9;</p><p>// Import this file to use console.log</p><p>import &quot;hardhat/console.sol&quot;;</p><p>// Switch this to your own contract address once deployed, for bookkeeping!</p><p>// Example Contract Address on Goerli: 0xDBa03676a2fBb6711CB652beF5B7416A53c1421D</p><p>contract BuyABCACoffee {</p><p>// Event to emit when a Memo is created.</p><p>event NewMemo(</p><p>address indexed from,</p><p>uint256 timestamp,</p><p>string name,</p><p>string message</p><p>);</p><p>// Memo struct.</p><p>struct Memo {</p><p>address from;</p><p>uint256 timestamp;</p><p>string name;</p><p>string message;</p><p>}</p><p>// Address of contract deployer. Marked payable so that</p><p>// we can withdraw to this address later.</p><p>address payable owner;</p><p>// List of all memos received from coffee purchases.</p><p>Memo[] memos;</p><p>constructor() {</p><p>// Store the address of the deployer as a payable address.</p><p>// When we withdraw funds, we&apos;ll withdraw here.</p><p>owner = payable(msg.sender);</p><p>}</p><p>/**</p><p>* @dev fetches all stored memos</p><p>*/</p><p>function getMemos() public view returns (Memo[] memory) {</p><p>return memos;</p><p>}</p><p>/**</p><p>* @dev buy a coffee for owner (sends an ETH tip and leaves a memo)</p><p>* @param _name name of the coffee purchaser</p><p>* @param _message a nice message from the purchaser</p><p>*/</p><p>function buyCoffee(string memory _name, string memory _message) public payable {</p><p>// Must accept more than 0 ETH for a coffee.</p><p>require(msg.value &gt; 0, &quot;can&apos;t buy coffee for free!&quot;);</p><p>// Add the memo to storage!</p><p>memos.push(Memo(</p><p>msg.sender,</p><p>block.timestamp,</p><p>_name,</p><p>_message</p><p>));</p><p>// Emit a NewMemo event with details about the memo.</p><p>emit NewMemo(</p><p>msg.sender,</p><p>block.timestamp,</p><p>_name,</p><p>_message</p><p>);</p><p>}</p><p>/**</p><p>* @dev send the entire balance stored in this contract to the owner</p><p>*/</p><p>function withdrawTips() public {</p><p>require(owner.send(address(this).balance));</p><p>}</p><p>}</p><p>2、在scripts目录鼠标右键或者左键点击<strong><em>3个点</em></strong>处，选“Add file”，输入buycoffee.js回车来新建文件。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1120c836ca85c1498034aa0a895a1898329b59a81a78266574fac4bf581b1bd8.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>3、在“buycoffee.js”文件里输入以下代码。（同样，ABC可以修改，需与前面保持一致。若前面改了，此处修改会较多） const hre = require(&quot;hardhat&quot;);</p><p>// Returns the Ether balance of a given address.</p><p>async function getBalance(address) {</p><p>const balanceBigInt = await hre.ethers.provider.getBalance(address);</p><p>return hre.ethers.utils.formatEther(balanceBigInt);</p><p>}</p><p>// Logs the Ether balances for a list of addresses.</p><p>async function printBalances(addresses) {</p><p>let idx = 0;</p><p>for (const address of addresses) {</p><p>console.log(`Address ${idx} balance: `, await getBalance(address));</p><p>idx ++;</p><p>}</p><p>}</p><p>// Logs the memos stored on-chain from coffee purchases.</p><p>async function printMemos(memos) {</p><p>for (const memo of memos) {</p><p>const timestamp = memo.timestamp;</p><p>const tipper = memo.name;</p><p>const tipperAddress = memo.from;</p><p>const message = memo.message;</p><p>console.log(`At ${timestamp}, ${tipper} (${tipperAddress}) said: &quot;${message}&quot;`);</p><p>}</p><p>}</p><p>async function main() {</p><p>// Get the example accounts we&apos;ll be working with.</p><p>const [owner, tipper, tipper2, tipper3] = await hre.ethers.getSigners();</p><p>// We get the contract to deploy.</p><p>const BuyABCACoffee = await hre.ethers.getContractFactory(&quot;BuyABCACoffee&quot;);</p><p>const buyABCACoffee = await BuyABCACoffee.deploy();</p><p>// Deploy the contract.</p><p>await buyABCACoffee.deployed();</p><p>console.log(&quot;BuyABCACoffee deployed to:&quot;, buyABCACoffee.address);</p><p>// Check balances before the coffee purchase.</p><p>const addresses = [owner.address, tipper.address, buyABCACoffee.address];</p><p>console.log(&quot;== start ==&quot;);</p><p>await printBalances(addresses);</p><p>// Buy the owner a few coffees.</p><p>const tip = {value: hre.ethers.utils.parseEther(&quot;1&quot;)};</p><p>await buyABCACoffee.connect(tipper).buyCoffee(&quot;Carolina&quot;, &quot;You&apos;re the best!&quot;, tip);</p><p>await buyABCACoffee.connect(tipper2).buyCoffee(&quot;Vitto&quot;, &quot;Amazing teacher&quot;, tip);</p><p>await buyABCACoffee.connect(tipper3).buyCoffee(&quot;Kay&quot;, &quot;I love my Proof of Knowledge&quot;, tip);</p><p>// Check balances after the coffee purchase.</p><p>console.log(&quot;== bought coffee ==&quot;);</p><p>await printBalances(addresses);</p><p>// Withdraw.</p><p>await buyABCACoffee.connect(owner).withdrawTips();</p><p>// Check balances after withdrawal.</p><p>console.log(&quot;== withdrawTips ==&quot;);</p><p>await printBalances(addresses);</p><p>// Check out the memos.</p><p>console.log(&quot;== memos ==&quot;);</p><p>const memos = await buyABCACoffee.getMemos();</p><p>printMemos(memos);</p><p>}</p><p>// We recommend this pattern to be able to use async/await everywhere</p><p>// and properly handle errors.</p><p>main()</p><p>.then(() =&gt; process.exit(0))</p><p>.catch((error) =&gt; {</p><p>console.error(error);</p><p>process.exit(1);</p><p>});</p><p>完成后如下图所示：</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/badb6d5b75c7966f17dceb0a285c836dc22279bb2f9f2874a136145c9db19209.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>4、点击deploy.js文件，将原文替换成以下代码。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/626536345f55e6f63f587777f8969a65dff2b044d9b49b96e3c2bb0e22faad70.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>// scripts/deploy.js</p><p>const hre = require(&quot;hardhat&quot;);</p><p>async function main() {</p><p>// We get the contract to deploy.</p><p>const BuyABCACoffee = await hre.ethers.getContractFactory(&quot;BuyABCACoffee&quot;);</p><p>const buyABCACoffee = await BuyABCACoffee.deploy();</p><p>await buyABCACoffee.deployed();</p><p>console.log(&quot;BuyABCACoffee deployed to:&quot;, buyABCACoffee.address);</p><p>}</p><p>// We recommend this pattern to be able to use async/await everywhere</p><p>// and properly handle errors.</p><p>main()</p><p>.then(() =&gt; process.exit(0))</p><p>.catch((error) =&gt; {</p><p>console.error(error);</p><p>process.exit(1);</p><p>});</p><p>5、在scripts目录左键点击右侧3个点处，选“Add file”，新建withdraw.js文件，并回车。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/799c617b4c473ac3959b9b72ed274459420ea875ee69c78dcc1d35b73fe0e335.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>6、在上一步新建的“withdraw.js”文件里，输入以下代码。</p><p>// scripts/withdraw.js</p><p>const hre = require(&quot;hardhat&quot;);</p><p>const abi = require(&quot;../artifacts/contracts/BuyABCACoffee.sol/BuyABCACoffee.json&quot;);</p><p>async function getBalance(provider, address) {</p><p>const balanceBigInt = await provider.getBalance(address);</p><p>return hre.ethers.utils.formatEther(balanceBigInt);</p><p>}</p><p>async function main() {</p><p>// Get the contract that has been deployed to Goerli.</p><p>const contractAddress=&quot;0x314Cb061D81759F339c6F026c86D09Ad528A31b5&quot;;</p><p>const contractABI = abi.abi;</p><p>// Get the node connection and wallet connection.</p><p>const provider = new hre.ethers.providers.AlchemyProvider(&quot;goerli&quot;, process.env.GOERLI_API_KEY);</p><p>// Ensure that signer is the SAME address as the original contract deployer,</p><p>// or else this script will fail with an error.</p><p>const signer = new hre.ethers.Wallet(process.env.PRIVATE_KEY, provider);</p><p>// Instantiate connected contract.</p><p>const buyABCACoffee = new hre.ethers.Contract(contractAddress, contractABI, signer);</p><p>// Check starting balances.</p><p>console.log(&quot;current balance of owner: &quot;, await getBalance(provider, signer.address), &quot;ETH&quot;);</p><p>const contractBalance = await getBalance(provider, buyABCACoffee.address);</p><p>console.log(&quot;current balance of contract: &quot;, await getBalance(provider, buyABCACoffee.address), &quot;ETH&quot;);</p><p>// Withdraw funds if there are funds to withdraw.</p><p>if (contractBalance !== &quot;0.0&quot;) {</p><p>console.log(&quot;withdrawing funds..&quot;)</p><p>const withdrawTxn = await buyABCACoffee.withdrawTips();</p><p>await withdrawTxn.wait();</p><p>} else {</p><p>console.log(&quot;no funds to withdraw!&quot;);</p><p>}</p><p>// Check ending balance.</p><p>console.log(&quot;current balance of owner: &quot;, await getBalance(provider, signer.address), &quot;ETH&quot;);</p><p>}</p><p>// We recommend this pattern to be able to use async/await everywhere</p><p>// and properly handle errors.</p><p>main()</p><p>.then(() =&gt; process.exit(0))</p><p>.catch((error) =&gt; {</p><p>console.error(error);</p><p>process.exit(1);</p><p>});</p><p>7、左键点击BuyABCACoffee-contracts右边三个点，选“Add file”，新建.env文件(<strong>注意，此文件最前面有小数点</strong>)。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2b87fc0b9e92000a1bb98d8ccf7b7358734ccf6da940b13b341b0094377f9e9c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>8、先暂时将以下代码输入.env文件</p><p>GOERLI_URL=<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eth-goerli.alchemyapi.io/v2/">https://eth-goerli.alchemyapi.io/v2/</a> GOERLI_API_KEY= PRIVATE_KEY= 9、登陆alchemy账号并创建ETH-Goerli的API（如何创建见 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">前序文章</a> 第4步） 点击VIEW KEY，然后复制下图所示API KEY，粘贴到上一步的GOERLI_API_KEY=后面；复制HTTPS，粘贴到上一步的GOERLI_URL=后面。 再去metamask钱包导出钱包私钥（如何导出见 <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/doger.eth/UwHqj3KpiH_YIgNV_KgkliLcf2fwatK8_cKiXAfZZ6E">前序文章</a> 第5步，最好新建一个新钱包），将私钥粘贴到上一步的PRIVATE_KEY=后面。 10、点击hardhat.config.js文件，并将原文替换成以下代码： // hardhat.config.js require(&quot;@nomiclabs/hardhat-ethers&quot;); require(&quot;@nomiclabs/hardhat-waffle&quot;); require(&apos;dotenv&apos;).config(); // You need to export an object to set up your config // Go to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://hardhat.org/config/">https://hardhat.org/config/</a> to learn more const GOERLI = process.env.GOERLI_URL; const PRIVATE = process.env.PRIVATE_KEY; //console.log(GOERLI); /** * @type import(&apos;hardhat/config&apos;).HardhatUserConfig */ module.exports = { solidity: &quot;0.8.9&quot;, networks: { goerli: { url: GOERLI, accounts: [PRIVATE] } } }; 四、代码完成，开始项目测试 1、又回到右边栏了，点击“Shell”，若观察回到上一层目录了，请执行<code>cd BuyABCACoffee-contracts</code> （同样<strong>ABC</strong>为你应与前面你设置的名字一样**）**切换到子目录中。没有则不管。以后遇到都需要这么处理，即cd +文件名 。如下图： 然后输入npx hardhat run scripts/buycoffee.js并回车。（中间会遇到有一次”？直接回车，以后遇到该问题也是如此操作）如下图： 当运行完成后，看图可发现我们的控制台又回到了上一层目录，同理我们通过输入cd BuyABCACoffee-contracts回到子目录。 2、输入npx hardhat run scripts/deploy.js并回车。(中间会遇到有一次”？直接回车，以后遇到该问题也是如此操作） 当出现如下图：deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3，则代表运行成功。当然，这只是尝试部署，还没真正到链上。 3、输入npx hardhat run scripts/deploy.js --network goerli并回车。 若出现下图:INSUFFICIENT_FUNDS代码，则代表钱包每天Goerli网上的ETH。去<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.goerlifaucet.com">https://www.goerlifaucet.com</a> 并登陆Alchemy 帐户以获得一些免费的测试币。 正常成功的部署应该是如下图所示，会出现deployed to：后面的地址就是我们部署的合约地址，复制下来后续步骤会要用到。 <strong>这里有的朋友可能等很久都不会出现合约地址,可以试着按下回车，或者直接去自己的钱包查看链上是否有合约部署记录。</strong> 4、输入npx hardhat run scripts/withdraw.js并回车（中间可能会有一次回车）。 五、部署dapp 1、先回到上一层magweek2(你们命名的可能不一样)，输入cd 并回车(如果已经回到上一层目录了，就不用管了),然后输入cd magweek2。 输入npx create-next-app buyabcacoffee-dapp，并回车 (此目录名可以自命名，后续需保持与此一致。中间可能有一次回车。 <strong>出现SUCCESS表示成功。</strong> 2、输入cd buyabcacoffee-dapp并回车，然后输入npm install --save ethers并回车。 3、安装成功后，左边栏不一定及时出现新目录，需要手动刷新。 （1）先点左边第二个按钮version control，直到出现红框出的buyabcacoffee即可。 （2）再点回第一个按钮file，等待更新目录，会等几分钟。 4、为了让dapp找到合约，需要把BuyABCACoffee产生的合约属性文件拷贝到dapp目录下。操作流程如下：（ABC如果前面有改，则是你们改的名字） （1）点开BuyABCACoffee-contracts目录，选择artifacts/contract/BuyABCACoffee.sol这个目录，选择其中叫BuyABCACoffee.json的文件，先复制其里面的内容到其他地方（比如新建一个记事本拷贝进去），点BuyABCACoffee.json文件右边的三个点，选“rename“，复制其文件名，如图 （2）点击buyabcacoffee-dapp目录右边的三个点，选择“Add folder“，新建utils文件夹。 （3）点击utils右边三个点，选择“Add file“，新建BuyABCACoffee.json文件，再将之前复制的内容拷贝到该文件，即完成。 5、打开pages目录，点击index.js文件，将原文用以下代码替换掉。 <strong>注意：①下面ABC几处同样需要和前面保持一致。②第19行代码“contractAddress”处填上第四大步第3点里面记录的合约地址。③名字（hymnmark</strong>有3处）可以改为任意名字。④@FinderTechnical<strong>处可以改成自己的twitter号。</strong> <code>import abi from &apos;../utils/BuyABCACoffee.json&apos;;</code> <code>import { ethers } from &quot;ethers&quot;;</code> <code>import Head from &apos;next/head&apos;</code> <code>import Image from &apos;next/image&apos;</code> <code>import React, { useEffect, useState } from &quot;react&quot;;</code> <code>import styles from &apos;../styles/Home.module.css&apos;</code> <code> </code> <code>export default function Home() {</code> <code>  // Contract Address &amp; ABI</code> <code>  const contractAddress = &quot;0x2a112B58765c93B0151C10D0Aa54a70698859676&quot;;</code> <code>  const contractABI = abi.abi;</code> <code> </code> <code>  // Component state</code> <code>  const [currentAccount, setCurrentAccount] = useState(&quot;&quot;);</code> <code>  const [name, setName] = useState(&quot;&quot;);</code> <code>  const [message, setMessage] = useState(&quot;&quot;);</code> <code>  const [memos, setMemos] = useState([]);</code> <code> </code> <code>  const onNameChange = (event) =&gt; {</code> <code>    setName(event.target.value);</code> <code>  }</code> <code> </code> <code>  const onMessageChange = (event) =&gt; {</code> <code>    setMessage(event.target.value);</code> <code>  }</code> <code> </code> <code>  // Wallet connection logic</code> <code>  const isWalletConnected = async () =&gt; {</code> <code>    try {</code> <code>      const { ethereum } = window;</code> <code> </code> <code>      const accounts = await ethereum.request({ method: &apos;eth_accounts&apos; })</code> <code>      console.log(&quot;accounts: &quot;, accounts);</code> <code> </code> <code>      if (accounts.length &gt; 0) {</code> <code>        const account = accounts[0];</code> <code>        console.log(&quot;wallet is connected! &quot; + account);</code> <code>      } else {</code> <code>        console.log(&quot;make sure MetaMask is connected&quot;);</code> <code>      }</code> <code>    } catch (error) {</code> <code>      console.log(&quot;error: &quot;, error);</code> <code>    }</code> <code>  }</code> <code> </code> <code>  const connectWallet = async () =&gt; {</code> <code>    try {</code> <code>      const { ethereum } = window;</code> <code> </code> <code>      if (!ethereum) {</code> <code>        console.log(&quot;please install MetaMask&quot;);</code> <code>      }</code> <code> </code> <code>      const accounts = await ethereum.request({</code> <code>        method: &apos;eth_requestAccounts&apos;</code> <code>      });</code> <code> </code> <code>      setCurrentAccount(accounts[0]);</code> <code>    } catch (error) {</code> <code>      console.log(error);</code> <code>    }</code> <code>  }</code> <code> </code> <code>  const buyCoffee = async () =&gt; {</code> <code>    try {</code> <code>      const { ethereum } = window;</code> <code> </code> <code>      if (ethereum) {</code> <code>        const provider = new ethers.providers.Web3Provider(ethereum, &quot;any&quot;);</code> <code>        const signer = provider.getSigner();</code> <code>        const buyABCACoffee = new ethers.Contract(</code> <code>          contractAddress,</code> <code>          contractABI,</code> <code>          signer</code> <code>        );</code> <code> </code> <code>        console.log(&quot;buying coffee..&quot;)</code> <code>        const coffeeTxn = await buyABCACoffee.buyCoffee(</code> <code>          name ? name : &quot;anon&quot;,</code> <code>          message ? message : &quot;Enjoy your coffee!&quot;,</code> <code>          { value: ethers.utils.parseEther(&quot;0.001&quot;) }</code> <code>        );</code> <code> </code> <code>        await coffeeTxn.wait();</code> <code> </code> <code>        console.log(&quot;mined &quot;, coffeeTxn.hash);</code> <code> </code> <code>        console.log(&quot;coffee purchased!&quot;);</code> <code> </code> <code>        // Clear the form fields.</code> <code>        setName(&quot;&quot;);</code> <code>        setMessage(&quot;&quot;);</code> <code>      }</code> <code>    } catch (error) {</code> <code>      console.log(error);</code> <code>    }</code> <code>  };</code> <code> </code> <code>  // Function to fetch all memos stored on-chain.</code> <code>  const getMemos = async () =&gt; {</code> <code>    try {</code> <code>      const { ethereum } = window;</code> <code>      if (ethereum) {</code> <code>        const provider = new ethers.providers.Web3Provider(ethereum);</code> <code>        const signer = provider.getSigner();</code> <code>        const buyABCACoffee = new ethers.Contract(</code> <code>          contractAddress,</code> <code>          contractABI,</code> <code>          signer</code> <code>        );</code> <code> </code> <code>        console.log(&quot;fetching memos from the blockchain..&quot;);</code> <code>        const memos = await buyABCACoffee.getMemos();</code> <code>        console.log(&quot;fetched!&quot;);</code> <code>        setMemos(memos);</code> <code>      } else {</code> <code>        console.log(&quot;Metamask is not connected&quot;);</code> <code>      }</code> <code> </code> <code>    } catch (error) {</code> <code>      console.log(error);</code> <code>    }</code> <code>  };</code> <code> </code> <code>  useEffect(() =&gt; {</code> <code>    let buyABCACoffee;</code> <code>    isWalletConnected();</code> <code>    getMemos();</code> <code> </code> <code>    // Create an event handler function for when someone sends</code> <code>    // us a new memo.</code> <code>    const onNewMemo = (from, timestamp, name, message) =&gt; {</code> <code>      console.log(&quot;Memo received: &quot;, from, timestamp, name, message);</code> <code>      setMemos((prevState) =&gt; [</code> <code>        ...prevState,</code> <code>        {</code> <code>          address: from,</code> <code>          timestamp: new Date(timestamp * 1000),</code> <code>          message,</code> <code>          name</code> <code>        }</code> <code>      ]);</code> <code>    };</code> <code> </code> <code>    const { ethereum } = window;</code> <code> </code> <code>    // Listen for new memo events.</code> <code>    if (ethereum) {</code> <code>      const provider = new ethers.providers.Web3Provider(ethereum, &quot;any&quot;);</code> <code>      const signer = provider.getSigner();</code> <code>      buyABCACoffee = new ethers.Contract(</code> <code>        contractAddress,</code> <code>        contractABI,</code> <code>        signer</code> <code>      );</code> <code> </code> <code>      buyABCACoffee.on(&quot;NewMemo&quot;, onNewMemo);</code> <code>    }</code> <code> </code> <code>    return () =&gt; {</code> <code>      if (buyABCACoffee) {</code> <code>        buyABCACoffee.off(&quot;NewMemo&quot;, onNewMemo);</code> <code>      }</code> <code>    }</code> <code>  }, []);</code> <code> </code> <code>  return (</code> <code>    &lt;div className={styles.container}&gt;</code> <code>      &lt;Head&gt;</code> <code>        &lt;title&gt;Buy hymnmark a Coffee!&lt;/title&gt;</code> <code>        &lt;meta name=&quot;description&quot; content=&quot;Tipping site&quot; /&gt;</code> <code>        &lt;link rel=&quot;icon&quot; href=&quot;/favicon.ico&quot; /&gt;</code> <code>      &lt;/Head&gt;</code> <code> </code> <code>      &lt;main className={styles.main}&gt;</code> <code>        &lt;h1 className={styles.title}&gt;</code> <code>  Buy hymnmark a Coffee!</code> <code>        &lt;/h1&gt;</code> <code> </code> <code>        {currentAccount ? (</code> <code>          &lt;div&gt;</code> <code>            &lt;form&gt;</code> <code>              &lt;div&gt;</code> <code>                &lt;label&gt;</code> <code>                  Name</code> <code>                &lt;/label&gt;</code> <code>                &lt;br /&gt;</code> <code> </code> <code>                &lt;input</code> <code>                  id=&quot;name&quot;</code> <code>                  type=&quot;text&quot;</code> <code>                  placeholder=&quot;anon&quot;</code> <code>                  onChange={onNameChange}</code> <code>                /&gt;</code> <code>              &lt;/div&gt;</code> <code>              &lt;br /&gt;</code> <code>              &lt;div&gt;</code> <code>                &lt;label&gt;</code> <code>                  Send hymnmark a message</code> <code>                &lt;/label&gt;</code> <code>                &lt;br /&gt;</code> <code> </code> <code>                &lt;textarea</code> <code>                  rows={3}</code> <code>                  placeholder=&quot;Enjoy your coffee!&quot;</code> <code>                  id=&quot;message&quot;</code> <code>                  onChange={onMessageChange}</code> <code>                  required</code> <code>                &gt;</code> <code>                &lt;/textarea&gt;</code> <code>              &lt;/div&gt;</code> <code>              &lt;div&gt;</code> <code>                &lt;button</code> <code>                  type=&quot;button&quot;</code> <code>                  onClick={buyCoffee}</code> <code>                &gt;</code> <code>                  Send 1 Coffee for 0.001ETH</code> <code>                &lt;/button&gt;</code> <code>              &lt;/div&gt;</code> <code>            &lt;/form&gt;</code> <code>          &lt;/div&gt;</code> <code>        ) : (</code> <code>            &lt;button onClick={connectWallet}&gt; Connect your wallet &lt;/button&gt;</code> <code>          )}</code> <code>      &lt;/main&gt;</code> <code> </code> <code>      {currentAccount &amp;&amp; (&lt;h1&gt;Memos received&lt;/h1&gt;)}</code> <code> </code> <code>      {currentAccount &amp;&amp; (memos.map((memo, idx) =&gt; {</code> <code>        return (</code> <code>          &lt;div key={idx} style={{ border: &quot;2px solid&quot;, &quot;borderRadius&quot;: &quot;5px&quot;, padding: &quot;5px&quot;, margin: &quot;5px&quot; }}&gt;</code> <code>            &lt;p style={{ &quot;fontWeight&quot;: &quot;bold&quot; }}&gt;&quot;{memo.message}&quot;&lt;/p&gt;</code> <code>            &lt;p&gt;From: {memo.name} at {memo.timestamp.toString()}&lt;/p&gt;</code> <code>          &lt;/div&gt;</code> <code>        )</code> <code>      }))}</code> <code> </code> <code>      &lt;footer className={styles.footer}&gt;</code> <code>        &lt;a</code> <code>          href=&quot;https://alchemy.com/?a=roadtoweb3weektwo&quot;</code> <code>          target=&quot;_blank&quot;</code> <code>          rel=&quot;noopener noreferrer&quot;</code> <code>        &gt;</code> <code>          Created by @FinderTechnical for Alchemy&apos;s Road to Web3 lesson two!</code> <code>        &lt;/a&gt;</code> <code>      &lt;/footer&gt;</code> <code>    &lt;/div&gt;</code> <code>  )</code> <code>}</code> 6、开始准备运行dapp了。点击最上面Files右边的三个点，选择“show hidden files“,显示.replit的文件。 7、点击.replit，将原文用以下代码替换：（若之前目录名字是自定义的，请换成你们自定义的） ，最后点击上方绿色按钮“<strong>RUN</strong>” run = &quot;npm --prefix=./buyabcacoffee-dapp run dev&quot; entrypoint = &apos;./buyabcacoffee-dapp/pages/index.js&apos; 8、最终出现如下图，即代表成功。我改过名字，所以显示是maggy。 点开右上角“open in a new tab”，可以试用下打赏功能。 9、点击“connect your wallet”连上钱包，进行打赏，然后可以查看钱包是否交易成功。至此所有任务步骤都已经完成，dapp已经完美运行。 10、切记！！！！！！！！删掉.env文件（env文件里有私钥），如下图。 六、发布与提交 1、发布，切记在发布钱删掉.env文件。发布没什么好说的，该填的框框填起来，就是无脑下一步，最后会有个<strong>网址</strong>保存下来作为最后的任务证明就行啦。 2、提交任务 Week 2: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://forms.gle/HeJrvT72mRcnasr99">https://forms.gle/HeJrvT72mRcnasr99</a> 打开该网址提交任务。 主要是提交repit项目地址即上一步保存的网址，类似于：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://replit.com/%E4%BD%A0%E7%9A%84github%E5%90%8D%E5%AD%97/%E9%A1%B9%E7%9B%AE%E5%90%8D%E5%AD%97?v=1">https://replit.com/你的github名字/项目名字?v=1</a> 这样子。 还有提交<strong>第四步第3点</strong>部署的合约地址，类似于：<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerli.etherscan.io/address/%E5%90%88%E7%BA%A6%E5%9C%B0%E5%9D%80%E3%80%82">https://goerli.etherscan.io/address/合约地址。</a></p>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/c5dd88ba3695e62a9b3d1c7ca7544b256170751873143f677e7b8adcaa0b068d.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Alchemy Road to Web3 活动前序:准备工作]]></title>
            <link>https://paragraph.com/@doger/alchemy-road-to-web3</link>
            <guid>a9vkIz4uzNn9AWHWgsHL</guid>
            <pubDate>Thu, 25 Aug 2022 02:18:32 GMT</pubDate>
            <description><![CDATA[本教程主要致力于解决许多小伙伴在本地搭建环境所遇到的各种问题，所以教程主要是通过网页端工具进行代码编译,减少由于本地环境不兼容导致的许多小白问题。 教程的编写主要是在@hymnxxk#6345上的优化而成。 主要是通过将github代码库与replit连接，并在replit网页上打开代码库进行代码编译，完成任务。 每周任务准备的通用步骤： 1、设置好科学上网工具（很关键） 2、注册https://github.com/ （已有的跳过），并登录。 3、注册https://replit.com/ （已有的跳过，可以用github直接登陆），登录自己的replit，并与和github账号连接同步，操作如下： （1）点击“create”按钮，然后选择“import from github”（2）继续点击“Connect GitHub to import your private repos.”（3）若前面保持了github的登录，则直接点如下图红框处，否则会进入github登录界面重新登录，然后再次回到上一步操作。（4）等一小段时间，会回到下图页面，再次点击红框处（显示已与前不同）（5）...]]></description>
            <content:encoded><![CDATA[<p><strong>本教程主要致力于解决许多小伙伴在本地搭建环境所遇到的各种问题，所以教程主要是通过网页端工具进行代码编译,减少由于本地环境不兼容导致的许多小白问题。</strong></p><p><strong>教程的编写主要是在@hymnxxk#6345上的优化而成。</strong></p><p>主要是通过将github代码库与replit连接，并在replit网页上打开代码库进行代码编译，完成任务。</p><p>每周任务准备的通用步骤：</p><p><strong>1、设置好科学上网工具（很关键）</strong></p><p><strong>2、注册</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/"><strong>https://github.com/</strong></a><strong> （已有的跳过），并登录。</strong></p><p><strong>3、注册</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://replit.com/"><strong>https://replit.com/</strong></a><strong> （已有的跳过，可以用github直接登陆），登录自己的replit，并与和github账号连接同步，操作如下：</strong></p><p>（1）点击“create”按钮，然后选择“import from github”</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e9f2c45a43f4298acd9a74a65ead8fd0205c88a2aa570886929dd9d2807d7488.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>（2）继续点击“Connect GitHub to import your private repos.”</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e073a7d18f5af5324e0a906e9439ecaa6f2086aeff4db9185c864e6d43e3df18.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>（3）若前面保持了github的登录，则直接点如下图红框处，否则会进入github登录界面重新登录，然后再次回到上一步操作。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9f65685e2d3ecab68368aa366aee4d140b93ce769ff37c6a6efbab4de662a8dc.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>（4）等一小段时间，会回到下图页面，再次点击红框处（显示已与前不同）</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/af829743bf3fc055729da3a24076a4b0e72b0c96805571224db0e017c0a535ef.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>（5）弹出新网页，会到下图页面，先选图中“only select repositories”，再选“All repositories”，才会让“Save”按钮变亮，然后点击“save”。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1fc04267f37f8b09ba98e1b9f03f6f5a59c61c769cb27ff79d59d31fab221a4e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>（6）再次回到replit，点击“create”，“import from github”，下图2可以看到自己github上面自己创建的各种代码库，表示replit已与github链接上，为每周任务做好准备。</p><p><strong><em>（注：图中的代码库为我已经做完任务的仓库，我们每次做任务之前都需要在github上面创建代码仓库，然后从这一步导入到replit，这是所有任务开始的基础，一定要看明白）</em></strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b72b7a1cef8b7dad7d96f787dd205bdcea2f89247e5d8e7aa63a923e4fe57b2f.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/99b8b4b23adf7d0d67da3137ee0e363870a525682732f6e0b358298e9d046058.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>4、注册</strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.alchemy.com/"><strong>https://www.alchemy.com/</strong></a><strong> 并创建Api</strong></p><p>（1）我们直接通过Gmail账号登陆,无需注册。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1fb46f4ed42910627449a50757f6518cfb2ec282361224e0b64c2c7a853a9ad3.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9dadf92102ae69d8d551d618bb2ca577e20727e2fd333f3c6ceddbb53ccd5e63.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>（2）创建API</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/20875ad50f5cbfbc1d8bb45414af0b10c44956a66eed7e78f092bfa7b6e8b685.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>5、导出metamask私钥</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/effea01715528c8433899c704be3a9c5292704c5ebcbedcb676e117f8842cba1.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/92045087349a705c62bcc7c9f9740de3845a2d8bc9175833e367c0efa1b8a955.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/eaa65bbc261302aa76d378feab3e82e9260c2673ddd166bd50b698975245d4f2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6d594be0daab952ac494759d0eac856e4b40f89c4deb198951d9fce5eccbaab8.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure>]]></content:encoded>
            <author>doger@newsletter.paragraph.com (Licrazy)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/6caef56d2c108b8969e7abdbfa0aa4666df6c30eda05d50634c8a3074c18dd6b.png" length="0" type="image/png"/>
        </item>
    </channel>
</rss>