安装 ETHERSCAN - CONTRACT VERIFICATION 插件
1、打开remix,点击左下角【插件管理】按钮

2、搜索 etherscan - contract verification,并点击激活按钮

3、点击左侧工具栏中的etherscan - contract verification图标

4、获取 Etherscan APIKey
点击右上角 登录注册

点击 左侧工具栏 API Keys,右上角添加 App Name,得到 API Key Token

(2)复制 API Key,并返回remix,点击 按钮 Save API Key


5、选中你要验证的合约源码
以Storage合约为例,之前已经部署到Goerli测试网,但未验证合约。

6、先编译合约,选中Goerli测试网,再打开 验证合约 插件,选择待验证的合约名字,输入构造参数的十六进制数据和 合约地址,点击按钮 Verify Contract
(1)编译合约

(2)选中Goerli测试网

(3)打开 验证合约 插件,选择待验证的合约名字,输入构造参数的十六进制数据和 合约地址,点击按钮 Verify Contract

(4)此刻查看你部署在Goerli测试网的合约是否已经被验证
补充
如何获取构造参数十六进制数据
以下列代码为例
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Name {
constructor(string memory name) {}
}
(1)先编译合约,再进入部署页面,之后点击Deploy函数后的小箭头

(2)输入构造参数,点击 2 指向的按钮,可复制 编码后的十六进制数据
abi.encode("ether") =
0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056574686572000000000000000000000000000000000000000000000000000000
-
原创
- 学分: 6
- 分类: 框架/库
- 标签:
合约开源验证
Remix