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