# Verifying your deployment

Description: How to verify an Ignition deployment

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/ignition/docs/guides/verify.mdx

  Components used in this page:
    - <Run cmd="..."/>: Runs a command in the terminal with npm/pnpm/yarn.
    - :::tip: A helpful tip callout block. Supports custom title `:::tip[Title]` and icon `:::tip{icon="name"}` syntax.

import Run from "@hh/Run.astro";

Once your Ignition module is tested and ready, the next step is to deploy it to a live network and verify the source code of each of its contracts.

Verifying a contract means making its source code public, along with the compiler settings you used, which allows anyone to compile it and compare the generated bytecode with the one that is deployed on-chain. Doing this is extremely important in an open platform like Ethereum.

In this guide we'll explain how to do this on all Hardhat-supported verification services, including the [Etherscan](https://etherscan.io/) explorer, the [Blockscout](https://blockscout.com/) explorer, and the [Sourcify](https://sourcify.dev/) verification service.

## Getting an API key from Etherscan

If you want to verify your contracts on Etherscan, you need an API key from Etherscan. Otherwise, Etherscan will be skipped and your contracts will be verified on the other services.

To get an API key, go to [their site](https://etherscan.io/login), sign in (or create an account if you don't have one) and open the "API Keys" tab. Then click the "Add" button and give a name to the API key you are creating (e.g. "Hardhat"). After that you'll see the newly created key in the list.

Open your Hardhat config and add the API key you just created as a configuration variable:

```ts
// hardhat.config.ts
import { configVariable, defineConfig } from "hardhat/config";

export default defineConfig({
  // ...rest of the config...
  verify: {
    etherscan: {
      apiKey: configVariable("ETHERSCAN_API_KEY"),
    },
  },
});
```

:::tip

You can find more info about using Hardhat configuration variables in the [configuration variable guide](/docs/guides/configuration-variables).

:::

## Deploying and verifying on the Sepolia testnet

We are going to use the [Sepolia testnet](https://ethereum.org/en/developers/docs/networks/#sepolia) to deploy and verify our Ignition module, so you need to add this network in your Hardhat config. Here we are using [Alchemy](https://alchemy.com/) to connect to the network.

```ts
// hardhat.config.ts
import { configVariable, defineConfig } from "hardhat/config";

// Go to https://alchemy.com, sign up, create a new App in
// its dashboard, and set the Hardhat configuration variable
// ALCHEMY_RPC_URL to the key
const ALCHEMY_RPC_URL = configVariable("ALCHEMY_RPC_URL");

// Replace this private key with your Sepolia test account private key
// To export your private key from Coinbase Wallet, go to
// Settings > Developer Settings > Show private key
// To export your private key from Metamask, open Metamask and
// go to Account Details > Export Private Key
// Beware: NEVER put real Ether into testing accounts
const SEPOLIA_PRIVATE_KEY = configVariable("SEPOLIA_PRIVATE_KEY");

export default defineConfig({
  // ...rest of your config...
  networks: {
    sepolia: {
      url: ALCHEMY_RPC_URL,
      accounts: [SEPOLIA_PRIVATE_KEY],
    },
  },
});
```

To deploy on Sepolia you need to send some Sepolia ether to the address that's going to be making the deployment. You can get testnet ether from a faucet, a service that distributes testing-ETH for free. Here is one for Sepolia:

- [Alchemy Sepolia Faucet](https://sepoliafaucet.com/)
- [QuickNode Sepolia Faucet](https://faucet.quicknode.com/ethereum/sepolia)

:::tip

This guide assumes you are using the contracts and Ignition module from the [quick start guide](/ignition/docs/getting-started), but the steps are the same for any deployment.

:::

Now you are ready to deploy your module to the testnet, but first we are going to make the source code of our contract unique. The reason we need to do this is that the sample code from the quick start guide is already verified in Sepolia, so if you try to verify it you'll get an error. If you are using your own contracts, you can likely skip this step.

Open your contract and add a comment with something unique, like your GitHub's username. Keep in mind that whatever you include here will be, like the rest of the code, publicly available on all enabled verification services:

```solidity
// Author: @john
contract Rocket {
```

You can now run the deployment using the newly added Sepolia network:

<Run command="hardhat ignition deploy ignition/modules/Apollo.ts --network sepolia --verify" />

The `--verify` flag is optional, but it tells Hardhat Ignition to verify the contracts after a successful deployment.

If you have an existing deployment and want to verify it, you can also run the `verify` task directly by passing the deployment ID:

<Run command="hardhat ignition verify chain-11155111" />

:::tip

If you get an error saying that the address does not have bytecode, it probably means that Etherscan has not indexed your contract yet. In that case, wait for a minute and then try again.

:::

After the task has successfully executed, for each deployed contract you'll see links to its publicly verified code.

To learn more about verifying, read our guide on [smart contract verification](/docs/guides/smart-contract-verification) documentation.
