原创

solidity合约验证


相关合约

TokenX.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TokenX is ERC20{
    constructor(uint256 initialSupply) public ERC20("Web03", "W03") {
        _mint(msg.sender, initialSupply);
    }
    string public constant url = 'web03.cn';
}

部署合约

部署TokenX.sol

地址:0x38451d7BC8c4d69B4d5a760E0fDaf4a0E3EE9305

交易哈希:https://rinkeby.etherscan.io/tx/0x61480174ae0904ae7a84385346048ba90dc207bff1003f0d438945610995d601

合并合约

如果合约代码简单,没有import其他合约,可忽略这一步,这一步的目的是将你当前合约和所有引用的合约都整合到一个文件里面

Home→MORE→PLUGIN MANAGER

搜索flattener并点击Activate

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614164701.png

插件激活成功,左侧会出现  Flattener 按钮,选中需要合并的合约

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614201315.png

点击Save VerifyTest_flat.sol,弹窗选中

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614201356.png

结果

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614201415.png

区块链浏览器认证合约

在区块链浏览器打开你的合约地址

https://rinkeby.etherscan.io/address/0x38451d7bc8c4d69b4d5a760e0fdaf4a0e3ee9305#code

点击 Verify and Publish

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614201533.png

Please enter the Contract Address you would like to verify:需要验证的合约地址【0x38451d7BC8c4d69B4d5a760E0fDaf4a0E3EE9305】

Please select Compiler Type:选择单文件,合约我们已经合并为一个sol文件【Solidity(Single file)】

Please select Compiler Version:选择部署合约的编译器版本【v0.8.14+commit.80d49f37】

Please select Open Source License Type:选择合约的开源许可类型【)3MIT License(MIT)】

填完点击按钮Continue按钮到下一步

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614201936.png

将刚刚合并后的合约代码全部拷贝到此处

Enter the Solidity Contract Code below*

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614170910.png

Constructor Arguments ABl-encoded (for contracts that were created with constructor parameters)

填写你创建合约的参数,一般在字节码最后一段

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614202928.png

最后进行人机身份认证,点击 Verify and Publish

这样就验证好了

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614201737.png

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614204420.png

验证合约方式2

下载remix插件 ETHERSCAN - CONTRACT VERIFICATION

可视化操作,填写key,填写地址 初始化参数 选择合约

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614205027.png

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614204804.png

key在区块浏览器申请

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614205109.png

https://web03-1252477692.cos.ap-guangzhou.myqcloud.com/blog/images/QQ%E6%88%AA%E5%9B%BE20220614205139.png

操作相对简单

以太坊
  • 作者:零三(联系作者)
  • 最后更新时间:2022-06-14 20:57
  • 版权声明:自由转载-非商用-非衍生-保持署名
  • 转载声明:来源地址 https://web03.cn