# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swisstronik.com/swisstronik-docs/development/guides/contract-verification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
