npm package: @qelt/hardhat-verify
Description: Hardhat plugin for verifying smart contracts on QELT blockchain
Author: QELT Team
Latest version: 1.0.12

# @qelt/hardhat-verify

Hardhat plugin for verifying smart contracts on QELT blockchain.

[![npm version](https://badge.fury.io/js/%40qelt%2Fhardhat-verify.svg)](https://www.npmjs.com/package/@qelt/hardhat-verify)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Features

- ✅ **Seamless Hardhat integration** - Works just like `@nomicfoundation/hardhat-verify`
- ✅ **Auto-detection** - Automatically detects contract from compiled artifacts
- ✅ **Multi-file support** - Handles complex projects with imports
- ✅ **Constructor arguments** - Simple encoding of constructor parameters
- ✅ **Library linking** - Supports contracts with external libraries
- ✅ **Progress tracking** - Real-time verification status with spinners
- ✅ **Async verification** - Queued verification for large contracts

## Installation

```bash
npm install --save-dev @qelt/hardhat-verify
```

## Usage

### 1. Import the plugin in your `hardhat.config.ts`:

```typescript
import "@qelt/hardhat-verify";

const config: HardhatUserConfig = {
  solidity: "0.8.20",
  networks: {
    qelt: {
      url: "https://mainnet.qelt.ai",
      chainId: 770,
      accounts: [process.env.PRIVATE_KEY!]
    },
    "qelt-testnet": {
      url: "https://testnet.qelt.ai",
      chainId: 771,
      accounts: [process.env.PRIVATE_KEY!]
    }
  },
  // Optional: Configure QELT verification
  qeltVerify: {
    networks: {
      qelt: {
        apiUrl: "https://mnindexer.qelt.ai",
        chainId: 770,
        explorerUrl: "https://qeltscan.ai"
      },
      "qelt-testnet": {
        apiUrl: "https://testnet-indexer.qelt.ai",
        chainId: 771,
        explorerUrl: "https://testnet.qeltscan.ai"
      }
    }
  }
};

export default config;
```

### 2. Verify your contract:

```bash
# After deploying your contract
npx hardhat verify --network qelt 0x1234567890123456789012345678901234567890
```

## Examples

### Simple Contract (No Constructor Arguments)

```bash
npx hardhat verify --network qelt 0x123...
```

### With Constructor Arguments

```bash
npx hardhat verify --network qelt 0x123... "My Token" "MTK" 1000000
```

### Specify Contract Name (if multiple contracts)

```bash
npx hardhat verify --network qelt \
  --contract contracts/MyToken.sol:MyToken \
  0x123... "My Token" "MTK" 1000000
```

### With Libraries

```bash
npx hardhat verify --network qelt \
  --libraries "SafeMath:0xabc...,OtherLib:0xdef..." \
  0x123... "arg1" "arg2"
```

### With Fully Qualified Library Names

```bash
npx hardhat verify --network qelt \
  --libraries "contracts/libs/Math.sol:SafeMath:0xabc..." \
  0x123...
```

## Configuration

### Default Configuration

If you don't provide a `qeltVerify` configuration, the plugin uses these defaults:

- **Mainnet (`qelt`)**: https://mnindexer.qelt.ai
- **Testnet (`qelt-testnet`)**: https://testnet-indexer.qelt.ai

### Custom API URL

You can override the API URL globally or per-network:

```typescript
qeltVerify: {
  // Global default
  apiUrl: "https://custom-api.example.com",
  
  // Network-specific (overrides global)
  networks: {
    qelt: {
      apiUrl: "https://mainnet-api.example.com",
      chainId: 770
    }
  }
}
```

## Programmatic Usage

You can also use the plugin programmatically in your deployment scripts:

```typescript
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { QeltVerifyClient, HardhatArtifactParser } from "@qelt/hardhat-verify";

async function main(hre: HardhatRuntimeEnvironment) {
  // Deploy contract
  const MyContract = await hre.ethers.getContractFactory("MyContract");
  const myContract = await MyContract.deploy("arg1", "arg2");
  await myContract.deployed();

  console.log(`Contract deployed to: ${myContract.address}`);

  // Verify programmatically
  const parser = new HardhatArtifactParser(hre.config.paths.root);
  const request = await parser.createVerificationRequest(
    "contracts/MyContract.sol:MyContract",
    myContract.address,
    "0x..." // encoded constructor args
  );

  const client = new QeltVerifyClient("https://mnindexer.qelt.ai");
  const response = await client.submitVerification(request);

  if (response.success) {
    console.log("✅ Contract verified!");
  }
}
```

## How It Works

1. **Artifact Parsing**: Reads your compiled Hardhat artifacts and build info
2. **Request Generation**: Creates a verification request with all compiler settings
3. **Submission**: Sends the request to the QELT verification API
4. **Polling**: Tracks verification status until completion
5. **Success**: Displays explorer link once verified

## Comparison with Etherscan Plugin

This plugin is designed as a drop-in replacement for `@nomicfoundation/hardhat-verify`:

| Feature | Etherscan Plugin | QELT Plugin |
|---------|-----------------|-------------|
| Command | `verify` | `verify` ✅ |
| Constructor args | ✅ | ✅ |
| Libraries | ✅ | ✅ |
| Multi-file | ✅ | ✅ |
| Auto-detection | ✅ | ✅ |
| Async queue | ❌ | ✅ |
| Progress tracking | Limited | Enhanced ✅ |

## Troubleshooting

### "No compiled contracts found"

Make sure to compile your contracts first:
```bash
npx hardhat compile
```

### "Multiple contracts found"

Specify which contract to verify using `--contract`:
```bash
npx hardhat verify --contract contracts/MyContract.sol:MyContract ...
```

### "Bytecode mismatch"

Ensure:
1. You're using the exact same compiler version
2. Optimization settings match what you used during deployment
3. Constructor arguments are correct and properly encoded
4. All libraries are deployed and addresses provided

### Enable Debug Logging

Set the `DEBUG` environment variable:
```bash
DEBUG=* npx hardhat verify ...
```

## API Reference

### Task Parameters

- `address` (required): Contract address to verify
- `constructorArgsParams` (optional): Constructor arguments (variadic)
- `--contract` (optional): Fully qualified contract name
- `--libraries` (optional): Comma-separated library mappings

### Configuration Type

```typescript
interface QeltVerifyConfig {
  apiUrl?: string;
  networks?: {
    [networkName: string]: {
      apiUrl: string;
      chainId: number;
      explorerUrl?: string;
    };
  };
}
```

## License

MIT

## Support

- **Documentation**: https://docs.qelt.ai
- **Explorer**: https://qeltscan.ai
- **Issues**: https://github.com/qelt-blockchain/hardhat-qelt-verify/issues

## Related Packages

- [`qelt-verify`](https://www.npmjs.com/package/qelt-verify) - Standalone CLI tool
- [`hardhat`](https://hardhat.org/) - Ethereum development environment

---

**Made with ❤️ by the QELT Team**