> For the complete documentation index, see [llms.txt](https://omega-6.gitbook.io/omega/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://omega-6.gitbook.io/omega/deploy-with-hardhat.md).

# Deploy with Hardhat

Hardhat is one of the most popular development frameworks for building and deploying smart contracts on EVM-compatible chains. Omega's compatibility with the EVM makes deploying via Hardhat fast and simple.

***

### 📦 Prerequisites

Make sure you have Node.js and npm installed.

Install Hardhat in your project directory:

```bash
npm init -y
npm install --save-dev hardhat
npx hardhat
```

Choose "Create a basic sample project" and follow the prompts.

***

### 🔧 Configure for Omega

1. Install `dotenv` and `@nomicfoundation/hardhat-toolbox`:

```bash
npm install dotenv
npm install --save-dev @nomicfoundation/hardhat-toolbox
```

2. Update `hardhat.config.js`:

```js
require('dotenv').config();
require('@nomicfoundation/hardhat-toolbox');

module.exports = {
  solidity: "0.8.20",
  networks: {
    omega: {
      url: process.env.RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
      chainId: 1313161768
    }
  }
};
```

3. Create a `.env` file:

```env
RPC_URL=https://0x4e454228.rpc.aurora-cloud.dev
PRIVATE_KEY=your_private_key
```

***

### ✍️ Example: Simple Contract

Here's a basic contract you can use:

```solidity
// contracts/Counter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Counter {
    uint256 public count;

    function increment() public {
        count += 1;
    }
}
```

***

### 🚀 Deploy Script

Create `scripts/deploy.js`:

```js
async function main() {
  const Counter = await ethers.getContractFactory("Counter");
  const counter = await Counter.deploy();
  await counter.deployed();
  console.log(`Counter deployed to: ${counter.address}`);
}

main()
  .then(() => process.exit(0))
  .catch(error => {
    console.error(error);
    process.exit(1);
  });
```

***

### 🧪 Compile and Deploy

Compile:

```bash
npx hardhat compile
```

Deploy to Omega:

```bash
npx hardhat run scripts/deploy.js --network omega
```

***

### 🔗 Useful Links

* 🔍 [Omega Explorer](https://0x4e454228.explorer.aurora-cloud.dev)
* 🌐 [Omega RPC](https://0x4e454228.rpc.aurora-cloud.dev)
* 📘 [Hardhat Docs](https://hardhat.org/hardhat-runner/docs/getting-started#overview)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://omega-6.gitbook.io/omega/deploy-with-hardhat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
