hardhat-zksync
hardhat-zksync copied to clipboard
Issue with Verifying Solidity Libraries on zkSync
Description
I am encountering an issue when attempting to verify a Solidity library on the zkSync network using the @matterlabs/hardhat-zksync
plugin. While I was able to deploy a Solidity library (MathLib
) successfully, the verification process fails with an error indicating a bytecode mismatch. This issue seems specific to the verification of Solidity libraries, as I was able to verify a regular contract (Greeter
) without any problems.
Steps to Reproduce
- You can either:
- clone this repo which uses the zksync-cli hardhat template: https://github.com/mshakeg/my-zksync-project.git
- create your own zksync-cli hardhat template
- Create a Solidity library (
MathLib.sol
) and a dependent contract (Calculator.sol
).
MathLib:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library MathLib {
function add(uint a, uint b) external pure returns (uint) {
return a + b;
}
}
Calculator:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./MathLib.sol";
contract Calculator {
function addNumbers(uint a, uint b) public view returns (uint) {
return MathLib.add(a, b);
}
}
- Deploy the
MathLib
library to the zkSync network:yarn hardhat deploy-zksync:libraries --private-key <private-key>
- Attempt to verify the
MathLib
library:yarn hardhat verify <MathLib address> --contract contracts/MathLib.sol:MathLib
. My library was deployed to0xE6f95768D5BADC7561EC7Fb6BCE2459F0fF69CDc
- Observe the following error:
Error in plugin @matterlabs/hardhat-zksync-verify: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts.
Possible causes are:
- Contract code changed after the deployment was executed. This includes code for seemingly unrelated contracts.
- A solidity file was added, moved, deleted or renamed after the deployment was executed. This includes files for seemingly unrelated contracts.
- Solidity compiler settings were modified after the deployment was executed (like the optimizer, target EVM, etc.).
- The given address is wrong.
- The selected network is wrong.
The Greeter
contract was verified automatically as part of the deployment process, it would be great if libraries were also verified automatically as part of yarn hardhat deploy-zksync:libraries
Thanks for the information. We are aware of this issue and we are working together with the backend verification team to resolve it.
As for the automatically verifying libraries as part of yarn hardhat deploy-zksync:libraries
, that would mean that our deploy plugin needs to depend on verify plugin, and we don't want that because this would introduce unnecessary dependencies between those plugins.