链接地址:https://hardhat.org/hardhat-runner/plugins/nomiclabs-hardhat-etherscan
This plugin helps you verify the source code for your Solidity contracts on Etherscan
npm install --save-dev @nomiclabs/hardhat-etherscan
require("@nomiclabs/hardhat-etherscan"); const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY etherscan: { apiKey: ETHERSCAN_API_KEY, },
注册后进入 https://etherscan.io/myapikey 获取
ETHERSCAN_API_KEY=WS6UZK83YCB1GI12236DB1DIDMN7BBVEZF2
const verify = async (contractAddress, args) => { console.log("Verifying contract..."); try { await run("verify:verify", { address: contractAddress, constructorArguments: args, }); } catch (e) { if (e.message.toLowerCase().includes("already verified")) { console.log("Already Verified!"); } else { console.log(e); } } };
本文作者:前端小毛
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!