Etherscan verification fails when using library
See original GitHub issueEnvironment information
brownie
Version: v1.17.0solc
Version: 0.8.9- Python Version: 3.9
- OS: linux
pragma solidity 0.8.9;
library MerkleLib {
function verifyProof(bytes32 root, bytes32 leaf, bytes32[] memory proof) public pure returns (bool) {
bytes32 currentHash = leaf;
for (uint i = 0; i < proof.length; i += 1) {
currentHash = parentHash(currentHash, proof[i]);
}
return currentHash == root;
}
function parentHash(bytes32 a, bytes32 b) public pure returns (bytes32) {
if (a < b) {
return keccak256(abi.encode(a, b));
} else {
return keccak256(abi.encode(b, a));
}
}
}
contract Test {
using MerkleLib for bytes32;
constructor() {
bytes32 root = bytes32(0);
bytes32 leaf = bytes32(0);
bytes32[] memory proof = new bytes32[](1);
root.verifyProof(leaf, proof);
}
}
This code compiles and runs. However, if I try to publish_source, it fails. Commenting out the verifyProof line allows it to be published. I believe this is not related to the recent flattener update, as this issue was on earlier versions of brownie as well.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Cannot verify contracts with libraries on Etherscan
Since the last week I have not been able to verify contracts on Etherscan if they use libraries. I was able to do...
Read more >Etherscan fails verification even for the matching bytecodes
Hi, I've found the weird issue that etherscan fails to match the bytecodes during verification by JSON-input even when they are the same...
Read more >Error in plugin @nomiclabs/hardhat-etherscan: The ...
Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify - with arguments · Ask Question.
Read more >Verify Smart Contracts with Etherscan Plugins
Both plugins can be used to automate the process of verifying contracts by locally detecting which contracts to verify and which Solidity libraries...
Read more >Verifying your contracts | Ethereum development ...
Verifying a contract means making its source code public, along with the compiler ... The first thing you need is an API key...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ah ok I see, just verified myself and the culprit is unlinked libraries. Just will require properly adding the below to the standard json input sent to etherscan
Odd, if you have a repo I could test against I can dig a little deeper to see what other layers are missing.