Skip to content

Conversation

@manuelwedler
Copy link
Contributor

@manuelwedler manuelwedler commented Oct 21, 2025

  • Because this PR includes a bug fix, relevant tests have been included.
  • Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team.
  • I didn't do anything of this.

Closes #6885

Related documentation change: NomicFoundation/hardhat-website#116

Changes

  • Adds the Sourcify class which implements the VerificationProvider
  • Sourcify is enabled by default, and called from the main verify task
  • Also adds the Sourcify subtask
  • Adds an additional --creation-tx-hash option to the verify task, which can optionally be provided by the user to more easily get a creation match
  • Sourcify URLs can be configured via the user config of the plugin. Note that Etherscan urls are configured via the global chain descriptors, but I think Sourcify doesn't fit into being added as an explorer.
  • I had to change how the compiler input is passed to the verify function of the VerificationProvider interface, because the Sourcify API expects the non-stringified version of the compiler input.

Example

Screenshot from 2025-10-21 15-10-00_0

@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: eea2a4a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/hardhat-verify Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Sourcify support to the hardhat-verify plugin, enabling contract verification through the Sourcify service alongside existing Etherscan and Blockscout providers.

Key changes:

  • Implements a new Sourcify class that integrates with the Sourcify API for contract verification
  • Adds optional --creation-tx-hash parameter to improve verification accuracy with Sourcify
  • Modifies the VerificationProvider interface to accept CompilerInput objects instead of stringified JSON

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
v-next/hardhat-verify/src/internal/sourcify.ts New Sourcify provider implementation with API integration
v-next/hardhat-verify/src/internal/sourcify.types.ts Type definitions for Sourcify API responses
v-next/hardhat-verify/src/internal/verification.ts Updates to support Sourcify provider and creation transaction hash
v-next/hardhat-verify/src/internal/types.ts Interface changes to accept CompilerInput and optional parameters
v-next/hardhat-verify/src/type-extensions.ts Configuration type extensions for Sourcify
v-next/hardhat-verify/src/internal/hook-handlers/config.ts Configuration resolver for Sourcify settings
v-next/hardhat-verify/src/internal/tasks/verify/sourcify/task-action.ts Task action implementation for Sourcify verification
v-next/hardhat-verify/src/internal/tasks/verify/utils.ts Updated task argument descriptions
v-next/hardhat-verify/src/internal/tasks/verify/types.ts Made constructorArgs optional and added creationTxHash
v-next/hardhat-verify/src/internal/tasks/verify/task-action.ts Added Sourcify to enabled providers list
v-next/hardhat-verify/src/internal/etherscan.ts Updated to use CompilerInput instead of stringified source code
v-next/hardhat-verify/src/internal/blockscout.ts Updated to use CompilerInput instead of stringified source code
v-next/hardhat-verify/src/index.ts Registered Sourcify task in plugin
v-next/hardhat-utils/src/request.ts Added throwOnError option to RequestOptions
v-next/hardhat-utils/src/internal/request.ts Implemented throwOnError parameter handling
v-next/hardhat-verify/test/sourcify.ts Comprehensive test suite for Sourcify functionality
v-next/hardhat-verify/test/etherscan.ts Updated tests for CompilerInput changes
v-next/hardhat-verify/test/blockscout.ts Updated tests for CompilerInput changes
v-next/hardhat-verify/test/tasks/verify/task-action.ts Added Sourcify to verification provider tests
v-next/hardhat-verify/test/hook-handlers/config.ts Added Sourcify configuration tests
v-next/hardhat-verify/README.md Updated documentation to mention Sourcify

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@michalbrabec michalbrabec self-requested a review October 22, 2025 07:23
@michalbrabec michalbrabec assigned michalbrabec and unassigned kanej Oct 22, 2025
@schaable schaable self-requested a review October 22, 2025 14:01
Copy link
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @manuelwedler, thanks a lot for the PR! I did a first pass and left some comments.

@manuelwedler
Copy link
Contributor Author

Btw, I added two additional changes:

With a recent update of the Sourcify server, it is now possible to reach the repo ui via redirect from the API. Therefore, I added a change to remove the repo URL from the configuration. This reduces the configuration overhead a bit.
If you disagree with the change, we can move back to have two configuration variables - url and apiUrl.

I also added a commit to show a link to the job info page of the Sourcify UI in case the verification fails. The page provides more info to the user for debugging why the verification fails. See for example: https://verify.sourcify.dev/jobs/75d1a316-dd30-4fb1-a889-e6427e3d3211

@schaable schaable force-pushed the verify-via-sourcify branch from 3d77f53 to 84cc2b4 Compare October 31, 2025 20:55
@schaable
Copy link
Member

Thanks, @manuelwedler! I’ll do another pass to fix any minor details I find along with the tests. After that, we’re good to go.

Regarding:

With a recent update of the Sourcify server, it is now possible to reach the repo ui via redirect from the API. Therefore, I added a change to remove the repo URL from the configuration. This reduces the configuration overhead a bit.
If you disagree with the change, we can move back to have two configuration variables - url and apiUrl.

Is this also available for custom Sourcify instances like https://sourcify-api-monad.blockvision.org/health
or https://verify-api.vechainstats.com/health ?

@alcuadrado
Copy link
Member

alcuadrado commented Oct 31, 2025

I updated the issue description to point to the new website's PR.

@manuelwedler
Copy link
Contributor Author

Is this also available for custom Sourcify instances like https://sourcify-api-monad.blockvision.org/health
or https://verify-api.vechainstats.com/health ?

Not yet I suppose. We are currently in contact with all custom instances we know of because some still only run the legacy API. Eventually, they should have these endpoints. The redirects are implemented inside the server code, such that it should only be a matter of upgrading to the newest server package/image.

@schaable schaable force-pushed the verify-via-sourcify branch from 244bcce to 6307578 Compare November 4, 2025 16:06
@schaable schaable added this pull request to the merge queue Nov 4, 2025
Merged via the queue into NomicFoundation:main with commit 9cf54ed Nov 4, 2025
84 checks passed
@manuelwedler
Copy link
Contributor Author

Thanks for finalizing the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sourcify support to hardhat-verify

5 participants