Skip to main content

@layerzerolabs/verify-contract

This plugin helps you verify source code for your solidity contracts.

Check the npm package to learn more.

Installation

  • Yarn
yarn add @layerzerolabs/verify-contract

npm install @layerzerolabs/verify-contract

pnpm add @layerzerolabs/verify-contract

Understanding CLI Options

Before diving into verification, familiarize yourself with the key CLI options provided by the @layerzerolabs/verify-contract package. To get a list of all options, you can run:

npx @layerzerolabs/verify-contract --help

Here's a breakdown of the primary CLI options you'll use:

  • -d, --deployments: Specifies the path to your contract deployment files.
  • --contracts: A comma-separated list of contract names to verify. If omitted, all contracts found in the specified directory will be considered.
  • -n, --network: The network where your contracts are deployed (e.g., mainnet, ropsten).
  • -u, --api-url: The API URL for the blockchain explorer or verification service.
  • -k, --api-key: Your API key for the blockchain explorer or verification service, if required.
  • --dry-run: Executes the command without making any actual changes or submissions. Useful for testing your setup.

Performing a Dry Run

A "dry run" is an essential step to ensure your commands are correctly set up before the actual verification. Here's a generic example of a dry run command:

npx @layerzerolabs/verify-contract -d "./deployments" -n "ethereum-mainnet" -u "https://api.etherscan.io/api" -k "your_api_key" --dry-run

This command simulates the verification process for contracts in the ./deployments directory on the ethereum-mainnet network, using the specified API_URL and API_KEY.

Contract Verification

After successfully completing a dry run, proceed with the verification by removing the --dry-run option. Here's a more generic command structure for verification on ethereum mainnet:

npx @layerzerolabs/verify-contract -d "./deployments" -n "ethereum-mainnet" -u "https://api.etherscan.io/api" -k "your_api_key"

For a specific contract or contracts within the deployments folder, use the --contracts option:

npx @layerzerolabs/verify-contract -d "./deployments" --contracts "MyContract,AnotherContract" -n "ethereum-mainnet" -u "https://api.etherscan.io/api" -k "your_api_key"