hardhat-zksync-verify-vyper

Guide on using the hardhat-zksync-verify-vyper plugin.

Description

The hardhat-zksync-verify-vyper plugin enables verification of Vyper smart contracts on the ZKsync Era network. Key features include:

  • Support for verifying Vyper contracts on ZKsync Era networks
  • Verification of contracts with constructor arguments
  • Support for encoded constructor parameters
  • Verification status checking capabilities
  • Programmatic verification support

Resources:

Alpha Release Warning: Due to verification context limitations, this plugin is labeled as alpha and is not recommended for production use.

Installation

Prerequisites

  • Node.js version 18 or higher
  • Hardhat version 2.16.0 or higher

Setup

Install the plugin using your preferred package manager:

yarn add -D @matterlabs/hardhat-zksync-verify-vyper

Import the package in your hardhat.config.ts file:

import "@matterlabs/hardhat-zksync-verify-vyper";

Configuration

Configuration Options

NameTypeDescriptionRequiredDefault
urlstringZKsync Era node URLYes-
ethNetworkstringEthereum network name or URLYes-
zksyncbooleanEnable ZKsync Era networkYes-
verifyURLstringVerification endpoint URLNoNetwork-specific default

Example Configuration

const config: HardhatUserConfig = {
  networks: {
    zkTestnet: {
      url: "https://sepolia.era.zksync.dev",
      ethNetwork: "sepolia",
      zksync: true,
      verifyURL: 'https://explorer.sepolia.era.zksync.dev/contract_verification'
    },
    zkMainnet: {
      url: "https://mainnet.era.zksync.io",
      ethNetwork: "mainnet",
      zksync: true,
      verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification"
    }
  }
};

export default config;

Additions

Added Tasks

Task NameDescription
verify:vyperVerifies a Vyper contract on ZKsync Era
verify-status:vyperChecks the status of a verification request

Added HRE Extensions

The plugin adds the following methods to the Hardhat Runtime Environment:

  • verify:verify:vyper: Programmatic contract verification
  • verify-status:vyper: Programmatic verification status check

Commands

Basic Verification

yarn hardhat verify:vyper --network <network> <contract address>

Verification with Contract Specification

yarn hardhat verify:vyper --network <network> <contract address> --contract <fully qualified name>

Verification with Constructor Arguments

yarn hardhat verify:vyper --network <network> <contract address> "arg1" "arg2"

Verification with Complex Constructor Arguments

yarn hardhat verify:vyper --network <network> <contract address> --constructor-args arguments.js

Check Verification Status

yarn hardhat verify-status:vyper --verification-id <your verification id>

Usage

Basic Contract Verification

  1. Deploy your Vyper contract
  2. Run the verification command:
yarn hardhat verify:vyper --network testnet <contract address>

Using Constructor Arguments

For simple arguments:

yarn hardhat verify:vyper --network testnet <contract address> "Hi there!"

For complex arguments, create an arguments.js:

module.exports = [
  "a string argument",
  "0xabcdef",
  "42",
  {
    property1: "one",
    property2: 2,
  }
];

Verify using the arguments file:

yarn hardhat verify:vyper --network testnet <contract address> --constructor-args arguments.js

Programmatic Verification

const verificationId = await hre.run("verify:verify:vyper", {
  address: contractAddress,
  contract: contractFullyQualifedName,
  constructorArguments: [...]
});

Troubleshooting

Known Limitations

  1. Verification Context: The plugin requires the exact same Vyper contracts list in your project's "contracts" folder as during deployment.
  2. Timing: It's strongly recommended to verify contracts immediately after deployment.
  3. Version Compatibility:
    • For plugin version <1.0.0: Compatible with ethers v5
    • For plugin version ≥1.0.0: Compatible with ethers v6 (recommended)

Common Issues

  1. "Bytecode doesn't match any of your local contracts":
    • Ensure all contracts present during deployment are still in your project
    • Verify immediately after deployment
  2. "Unknown compiler version":
    • Use a supported compiler version
    • Check the ZKsync Era documentation for compatible versions

For more help, please refer to the GitHub issues.


Made with ❤️ by the ZKsync Community