hardhat-deploy: Verification of libraries with linked libraries fail

Describe the bug The request to etherscan to verify libraries with linked libraries fail. Etherscan cannot resolve linked libraries from the payload the plugin is sending, following the solidity-standard-json-input format.

To Reproduce Created a project that reproduces the issue: https://github.com/tuler/hardhat-deploy-etherscan-library

The project have two libraries, Math and Util, both already deployed to goerli. Library A is already verified successfully. Library B links to library A, but verification fails, following this command:

npx hardhat --network goerli etherscan-verify --api-key <etherscan_api_key>

Expected behavior Library should verify.

versions

  • hardhat-deploy 0.9.24
  • hardhat 2.8.2
  • nodejs 16

Additional context The hardhat etherscan plugin works well. Details in the repo README.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15 (13 by maintainers)

Commits related to this issue

Most upvoted comments

/Sure, in etherscan.js, where the libraries are added to the settings for the payload, I simply changed the string to reflect the actual library being used, as you detailed in your own repo. In my case, the libraries are located in contracts/libraries.

if (deployment.libraries) {
            const settings = solcInput.settings;
            settings.libraries = settings.libraries || {};
            for (const libraryName of Object.keys(deployment.libraries)) {
                // The line below implements the 'ad-hoc fix for etherscan weirdness. 
                let cont = `contracts/libraries/${libraryName}.sol`;
                if (!settings.libraries[cont]) {
                    settings.libraries[cont] = {};
                }
                settings.libraries[cont][libraryName] =
                    deployment.libraries[libraryName];
            }
        }