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

post image

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

Scroll 现在估值为 $ 1,8 B

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

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

往期教程:

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

post image

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

步骤1、获得测试网代币

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

登录 https://scroll.io/alpha,并在 metamask 中添加 Scroll Alpha Testnet 网络

post image

转到 https://scroll.io/alpha/bridge ,并将一些 goerli ETH 桥接到 Scroll Goerli ETH。

post image

开始桥接

post image

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

步骤2、获得wETH

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

前往 https://uniswap-v3.scroll.io/#/swap 将 ETH 兑换成 wETH;

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

post image

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

  1. 创建我们自己的合约并验证其代码

  2. 创建代币并为其提供流动性

  3. 在 Uniswap 上交换

步骤3、创建我们的合约

转到 remix.ethereum.org 点击create new file,给文件取个名字,名称后面记得加 .sol

post image

本教程的文件名叫 alphascroll.sol

post image

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

// 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);
    }
}
post image

我们转到soliditycompiler并点击compile(编译)

post image

(选)也可以用指令编译:

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

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

post image

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

post image

(选)也可以用指令部署:

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
post image

选择“Injected Provider Metamask”作为环境

post image

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

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

在 “VALUE “字段中输入1;
从Wei切换到Gwei;
在 “unit256_unlock time “字段中输入1696118400;

检查下图

post image

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

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

post image

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

如下图:

post image

现在我们转到TAB合约,核实合同;

post image

点击继续

post image

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

post image

如果你做的一切都正确,你会得到如下结果:

post image

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

post image

步骤4、创建自己的代币

登录:https://docs.openzeppelin.com/contracts/4.x/wizard

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

post image

从屏幕右侧复制所有代码,然后在新窗口中再次访问Remix网站。再次创建名为 ALTKN.sol 的新文件(在我的例子中)并粘贴到那里。

post image

转到solidity编译器并编译

post image

转到 DEPLOY & RUN TRANSACTIONS 并部署。

post image

复制合约地址,在MetaMask中导入代币;

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

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

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

在这里添加我们的代币

post image

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

步骤6、添加流动性

转到 POOL 选项,点击new position;

post image

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

post image
post image
post image

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

本篇内容就到这里,更多信息请关注:

加密狗推特:https://twitter.com/JiamigouCn

电报:https://t.me/JIAMIGOU002