# Deploying the Smart Contract

&#x20;         After successfully compiling your contract, you can proceed to deploy it to the **ICB Testnet**.

&#x20;         To do so, update the `ignition/modules/Counter.js` file in your project with the necessary deployment logic:

```js
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

module.exports = buildModule("CounterModule", (m) => {
  const initialNumber = m.getParameter("initialNumber", 0);

  const counter = m.contract("Counter", []);

  if (initialNumber !== 0) {
    m.call(counter, "setNumber", [initialNumber]);
  }

  return { counter };
});
```

&#x20;         You'll also need to have **testnet ICBT** or **ICBX tokens** in your wallet. If you haven't obtained them yet, refer to the [Prerequisites](https://app.gitbook.com/o/jGflGFSUbio8Lp3Wxw6k/s/NGHmFVO7DlELOLs4PSVs/~/changes/81/build-on-icb-network/hardhat/prerequisites/~/page) section. Without sufficient funds, the deployment will not succeed!

&#x20;         Once ready, execute the following command to deploy your Counter contract:

## ICB Mainnet &#x20;

```bash
npx hardhat ignition deploy ./ignition/modules/Counter.js --network ICBMainnet
```

<figure><img src="/files/hErKrFIkH5z5BwwlrgKu" alt=""><figcaption></figcaption></figure>

## ICB Testnet

<figure><img src="/files/34mQ6Yer8MC3a32s3oSk" alt=""><figcaption></figcaption></figure>

&#x20;         The contract will be deployed to either the **ICB Mainnet** or **ICB Testnet**, depending on the network specified in your deployment command.

&#x20;         Once deployed, you can check the status and details of the contract using the appropriate block explorer — [**ICBScan Mainnet** ](https://icbscan.io/)or [**ICBScan Testnet**.](https://testnet.icbscan.io/) Simply search for the contract address returned by your deploy script.

&#x20;         To interact with your contract via the block explorer, it must first be **verified** — either by you or someone else. Since the contract provided above is already verified, you should be able to view and interact with your deployed version right away.


---

# 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.icb.network/build-on-icb-network/hardhat/deploying-the-smart-contract.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.
