# Contract verification

This page describes how you can verify code of your smart contract. To do it, we will use hardhat to simplify process of contract verification.

### Configuration

Open your Hardhat config file and add the following:

```javascript
module.exports = {
  // ...rest of the config...
  etherscan: {
    apiKey: `ANY_STRING_WILL_DO`,
    customChains: [
      {
        network: "swisstronik",
        chainId: 1291,
        urls: {
          apiURL: "https://explorer-evm.testnet.swisstronik.com/api",
          browserURL: "https://explorer-evm.testnet.swisstronik.com",
        },
      },
    ],
  },
};
```

Right now, there is no API key required to verify your contract. Also note, that `network` name in `customChains` should be same as network name in `networks` field.

### Verify contract

#### Using Hardhat CLI

Once you modified your hardhat config, you are ready to verify your contract using the following hardhat command:

```bash
hardhat verify ADDRESS_OF_DEPLOYED_CONTRACT \
    --contract PATH_TO_CONTRACT \
    [CONSTRUCTOR_PARAMS]
```

#### Using script

To automate verification of deployed contract, you can add the following to your deployment script

```javascript
// ... your deployment script   
 
await hre.run("verify:verify", {
      address: contract.target, // address of deployed contract
      constructorArguments: [JAN_1ST_2030], // constructor arguments
    });
    
// ... rest of your deployment script
```

You can find full example here: <https://github.com/SigmaGmbH/swisstronik-tutorials/blob/main/Contract_verification_hardhat/scripts/deploy_verify.js>
