安装 ETHERSCAN - CONTRACT VERIFICATION 插件
1、打开remix,点击左下角【插件管理】按钮
![1.png](https://img.learnblockchain.cn/attachments/2024/03/TMnAcKXE66050a529d276.png)
2、搜索 etherscan - contract verification,并点击激活按钮
![8d103fe5674f4124882b1a540c007aad.png](https://img.learnblockchain.cn/attachments/2024/03/Fu1HnxsB66050af4362eb.png)
3、点击左侧工具栏中的etherscan - contract verification图标
![b4cf2843c0054f4184a7fff385def933.png](https://img.learnblockchain.cn/attachments/2024/03/r8xEEGRg66050b0426b28.png)
4、获取 Etherscan APIKey
点击右上角 登录注册
![405785328e7a41748b38839787f4a15a.png](https://img.learnblockchain.cn/attachments/2024/03/yQdM3jZ666050b1ed4a61.png)
点击 左侧工具栏 API Keys,右上角添加 App Name,得到 API Key Token
![5917a09421504bfa8f6d7702330d68e6.png](https://img.learnblockchain.cn/attachments/2024/03/ItK0OkKW66050b565a5df.png)
(2)复制 API Key,并返回remix,点击 按钮 Save API Key
![759c5b6a963c4224b098f5a33d431409.png](https://img.learnblockchain.cn/attachments/2024/03/M3TAh7zG66050b673e202.png)
![d8033971746d404c901404b38f8e18b9.png](https://img.learnblockchain.cn/attachments/2024/03/wr5Bq9ie66050b852ce6d.png)
5、选中你要验证的合约源码
以Storage合约为例,之前已经部署到Goerli测试网,但未验证合约。
![9e65ed37ab504290a25045fa024d1019.png](https://img.learnblockchain.cn/attachments/2024/03/0ya2ncap66050ba88bce9.png)
6、先编译合约,选中Goerli测试网,再打开 验证合约 插件,选择待验证的合约名字,输入构造参数的十六进制数据和 合约地址,点击按钮 Verify Contract
(1)编译合约
![137387cde70141dcae32e233e36c0e9c.png](https://img.learnblockchain.cn/attachments/2024/03/AHCFGTxL66050bc804620.png)
(2)选中Goerli测试网
![113041d5a9f14ebfb4d0bc2d88636552.png](https://img.learnblockchain.cn/attachments/2024/03/jdCMOrAB66050bd417e43.png)
(3)打开 验证合约 插件,选择待验证的合约名字,输入构造参数的十六进制数据和 合约地址,点击按钮 Verify Contract
![1f9c807c07484c8285c165d493a790f5.png](https://img.learnblockchain.cn/attachments/2024/03/fZxQvLeu66050bf32c9dd.png)
(4)此刻查看你部署在Goerli测试网的合约是否已经被验证
补充
如何获取构造参数十六进制数据
以下列代码为例
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Name {
constructor(string memory name) {}
}
(1)先编译合约,再进入部署页面,之后点击Deploy函数后的小箭头
![7cf943bc393a4b3f89293d5d19f06292.png](https://img.learnblockchain.cn/attachments/2024/03/UhKxtUGk66050c272cd95.png)
(2)输入构造参数,点击 2 指向的按钮,可复制 编码后的十六进制数据
abi.encode("ether") =
0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056574686572000000000000000000000000000000000000000000000000000000
-
原创
- 学分: 6
- 分类: 框架/库
- 标签:
合约开源验证
Remix