# 加密狗整编空投第163篇：在Scroll测试网上部署智能合约、发行代币的教程 - 加密狗 - Medium

By [wowto](https://paragraph.com/@wowto) · 2023-04-04

---

![](https://storage.googleapis.com/papyrus_images/274593a8f8c0eeb3b57b6f6b3bf9f7915c3f2df3ce439d5a7f63b26932b607ca.webp)

Scroll 最近成功从 Polychain 资本、红杉资本等知名 VC 筹集了 5000 万美元。总体而言，Scroll 成功筹集了 8300 万美元。

Scroll 现在估值为 $ 1,8 B

Scroll 是基于以太坊上 zkEVM 的 zkRollup，提供与现有以太坊应用程序和工具的原生兼容性。简单来说，它是一个新的以太坊第 2 层网络。

目前，alpha 测试网阶段正在进行中，在 pre-alpha 版本期间，实现了 100 万个唯一地址和 1600 万笔交易

往期教程：
-----

请记住，每个测试网上至少需要 100 笔交易
----------------------

![](https://storage.googleapis.com/papyrus_images/22b8f4c0a7fb56c01014931d14207e90c90650831e8ba3678d7b2eee8ec5b528.webp)

今天我们要做一些桥接测试，创建我们自己的合约、代币并进行 100 多笔交易，加大账号权重为后期空投做准备。具体步骤如下：

步骤1、获得测试网代币
-----------

首先我们需要使用scroll bridge，以便获得scroll goerli ETH。

登录 [https://scroll.io/alpha](https://scroll.io/alpha)，并在 metamask 中添加 Scroll Alpha Testnet 网络

![](https://storage.googleapis.com/papyrus_images/31dc44d9c6ea0fbe86aa5c73f93eebcce0d4854f06148fa09805cb30026d4f11.webp)

转到 [https://scroll.io/alpha/bridge](https://scroll.io/alpha/bridge) ，并将一些 goerli ETH 桥接到 Scroll Goerli ETH。

![](https://storage.googleapis.com/papyrus_images/8ff4ec48ffe92beec7aee0465132b5e501848f68d242a47812468a1b4bf68ee4.webp)

开始桥接

![](https://storage.googleapis.com/papyrus_images/71ea9344126f405817ba2076d0a28bec5736e182d39e4f080b3cef44ca5b85a0.webp)

这个过程需要等30分钟到1个小时以上。

步骤2、获得wETH
----------

获得scroll ETH 后，我们使用 scroll-uniswap 交换一些 wETH；

前往 [https://uniswap-v3.scroll.io/#/swap](https://uniswap-v3.scroll.io/#/swap) 将 ETH 兑换成 wETH；

**我建议尽可能多地获得goerli水龙头和桥接器**。

![](https://storage.googleapis.com/papyrus_images/6c01309f45b5797a8dc8ec30b9f718107a65097cffb67b3c08145c9c97b93b50.webp)

到这里我们只做了本教程的50%，我们还要做下面这些事情：

1.  创建我们自己的合约并验证其代码
    
2.  创建代币并为其提供流动性
    
3.  在 Uniswap 上交换
    

步骤3、创建我们的合约
-----------

转到 [remix.ethereum.org](https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.18+commit.87f61d96.js) 点击create new file，给文件取个名字，名称后面记得加 .sol

![](https://storage.googleapis.com/papyrus_images/6bb4985993218456771c867a04bc31c9db12ff9f72ebb57c0ca2fede0d324a13.webp)

本教程的文件名叫 alphascroll.sol

![](https://storage.googleapis.com/papyrus_images/9d5e3c1823054cccd7c1579343f76485caf059ce422bf307e339782e2bb628bc.webp)

将下面的代码放在屏幕右侧

    // SPDX-License-Identifier: UNLICENSED
    pragma solidity ^0.8.9;
    contract Lock {
        uint public unlockTime;
        address payable public owner;
    event Withdrawal(uint amount, uint when);
    constructor(uint _unlockTime) payable {
            require(
                block.timestamp < _unlockTime,
                "Unlock time should be in the future"
            );
    unlockTime = _unlockTime;
            owner = payable(msg.sender);
        }
    function withdraw() public {
            require(block.timestamp >= unlockTime, "You can't withdraw yet");
            require(msg.sender == owner, "You aren't the owner");
    emit Withdrawal(address(this).balance, block.timestamp);
    owner.transfer(address(this).balance);
        }
    }
    

![](https://storage.googleapis.com/papyrus_images/11faaa09d9c2a8a1f728885feb3b36526845f2ed12a81e14ec5b0f260231fc4a.webp)

我们转到soliditycompiler并点击compile（编译）

![](https://storage.googleapis.com/papyrus_images/7664cff676308f617c0faa07c6448cd40683d019169212da49effa68147ac9c7.webp)

（选）也可以用指令编译：

    Go to the Solidity Compiler from the left-panel -> click on 'Compile cryptomarketblog.sol' -> If there is no error you'll see a green tick on solidity compiler button
    

编译后我们看到这样的画面

![](https://storage.googleapis.com/papyrus_images/14e5eac8a4fe506c5af083032fc8eee77a8bf95a05ddb72bd03b8959faace453.webp)

现在我们点击左侧的部署和运行交易图标

![](https://storage.googleapis.com/papyrus_images/4f3dec7e08038da88c5bf5b1d2a283165e0294fb0aa8ddb31440512152525f3f.webp)

（选）也可以用指令部署：

    Go to the Deploy & Run Transactions sidebar from the left-panel -> Select environment as 'Injected Provider - MetaMask'then you will get a MetaMask pop-up -> Click on connect -> Click on Deploy -> confirm MetaMask transaction
    

![](https://storage.googleapis.com/papyrus_images/e0d9869850724fe781b20dff711fe9af2fff66ea5334ad0fd76463d91591e2f4.webp)

选择“Injected Provider Metamask”作为环境

![](https://storage.googleapis.com/papyrus_images/c391697a82a8ca4bb283de421d668fe751610035c13dc147d420e140f31ac9b6.webp)

这里会弹出一个MetaMask窗口，批准。

现在你可以看到你的钱包地址就在环境下面。

在 “VALUE “字段中输入1；  
从Wei切换到Gwei；  
在 “unit256\_unlock time “字段中输入1696118400；

检查下图

![](https://storage.googleapis.com/papyrus_images/5f235a104ae6f7214c4ee06e00ad86424c5cc2d56beb9f88f9b8b8d647227549.webp)

现在填写完所有内容后，点击deploy图标并在 metamask 上确认（**确保你在ETH Goerli network**）

几分钟后可以看到这样的结果：

![](https://storage.googleapis.com/papyrus_images/195e4b2b9ab63026dce0e84e7bc0c1455ed7ed68cb2534cf11bd07133fb750f2.webp)

现在我们在ETH explorer中打开最后一笔交易，并打开合约。

如下图：

![](https://storage.googleapis.com/papyrus_images/d2d98293a0e96f0af81e25d581f8ac68db40653678e7ee0ed7c2ffb1299444a5.webp)

现在我们转到TAB合约，核实合同；

![](https://storage.googleapis.com/papyrus_images/7640e9eee9f107c6342a2e056c7c327ff940aef7a3034a11107f5d1c15932b24.webp)

点击继续

![](https://storage.googleapis.com/papyrus_images/2ed99c5e3d02c0011efd8151ae82d10e0a9bef0c0614e67f7e5096ec4d412617.webp)

现在你看到这里有一个大的空框。回到remix，复制该代码，点击验证并发布。

![](https://storage.googleapis.com/papyrus_images/af937888651db7041b8a6f3af31b3e9cea2358db4256c709a650b270ede940e7.webp)

如果你做的一切都正确，你会得到如下结果：

![](https://storage.googleapis.com/papyrus_images/82a4f7dd579b97bf029eaa5812d2f2ef4e8a06ed37f19d83548e513b36740d51.webp)

现在我们再次检查合同，看它是否得到验证。

![](https://storage.googleapis.com/papyrus_images/22827ba9d741647fea78c282516c07fcaed5662ef0b2c38419373ebea623e76b.webp)

步骤4、创建自己的代币
-----------

登录：[https://docs.openzeppelin.com/contracts/4.x/wizard](https://docs.openzeppelin.com/contracts/4.x/wizard)

参照下图设置值，其他所有字段保持原样。

![](https://storage.googleapis.com/papyrus_images/29ed39842e6d0f952b34af55be86b3fd6d91886eeecb10fdd4e891beac1fa46e.webp)

从屏幕右侧复制所有代码，然后在新窗口中再次访问[Remix](https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.18+commit.87f61d96.js)网站。再次创建名为 ALTKN.sol 的新文件（在我的例子中）并粘贴到那里。

![](https://storage.googleapis.com/papyrus_images/e76d7e2880d9588e97f644b4535c3c64189f8613813852b3fcc4d2f445563bac.webp)

转到solidity编译器并编译

![](https://storage.googleapis.com/papyrus_images/c68a509b5fdb67c19a40ba2f8bb1324feaad1ec05efc3ce8957827e06335ec19.webp)

转到 DEPLOY & RUN TRANSACTIONS 并部署。

![](https://storage.googleapis.com/papyrus_images/4933e65719e614ccbdf963c763a588f8be388b4135776dbf2ec4d355aa2f2a07.webp)

复制合约地址，在MetaMask中导入代币；

步骤5、测试代币运行流畅性
-------------

现在我们准备在 uniswap-scroll 中测试我们的代币

登录 [https://uniswap-v3.scroll.io/#/pool](https://uniswap-v3.scroll.io/#/swap) 使用scroll alpha 网络连接。

在这里添加我们的代币

![](https://storage.googleapis.com/papyrus_images/3b6fb711c1b7b333c3e811faa8806db2ad61ca5d0d4c63ff2a82f6ca4928ef48.webp)

下方可以看到我们 ALPHA 自定义代币。

步骤6、添加流动性
---------

转到 POOL 选项，点击new position；

![](https://storage.googleapis.com/papyrus_images/e07c0b8cfbd9cecec207b8c6afbef6477040da711c548a1b79ea41f19c6b2637.webp)

第一次设置的时候，你要填一些数值来创建初始价格和流动性。之后你会得到像下图这样的情况：

![](https://storage.googleapis.com/papyrus_images/1c08d3f339cc6bbaff4c6b4be7568a349fad9c9e3cceca590634d8705ad56b71.webp)

![](https://storage.googleapis.com/papyrus_images/9109e0025a7de010dd98fefa5602391bb52c11f769ba53950f9b66ca89299eaf.webp)

![](https://storage.googleapis.com/papyrus_images/8ebc5ff820b485b523e79d770a70e5d062b813aa6741c810310f6f74b6e8e2b5.webp)

到了这一步，说明你的部署已经全部完成了，你可以自己进行100笔代币交换。

本篇内容就到这里，更多信息请关注：

加密狗推特：[https://twitter.com/JiamigouCn](https://twitter.com/JiamigouCn)

电报：[https://t.me/JIAMIGOU002](https://t.me/JIAMIGOU002)

---

*Originally published on [wowto](https://paragraph.com/@wowto/163-scroll-medium)*
