# HardHat

### Hardhat Setup

> 💡 **New to Hardhat?**\
> Check out the [Hardhat Quick Start Guide](https://hardhat.org/getting-started/#quick-start#overview) for basics.

#### Project Setup

**1. Configure Your Account**

To deploy contracts to UOMI networks, you'll need to export your private key from MetaMask:

1. Open MetaMask
2. Select your account
3. Click the three dots menu
4. Go to "Account Details"
5. Select "Export Private Key"
6. Enter your password to confirm

You'll get a 64-character hex string like:

```
60ed0dd24087f00faea4e2b556c74ebfa2f0e705f8169733b01530ce4c619883
```

**2. Store Your Private Key**

Create `private.json` in your project root:

```json
{
  "privateKey": "YOUR_PRIVATE_KEY_HERE"
}
```

> ⚠️ **Security Warning**\
> Never commit your private key to version control. Add `private.json` to your `.gitignore` file.

**3. Configure Networks**

Modify your `hardhat.config.js`:

```javascript
const { privateKey } = require("./private.json");

module.exports = {
  networks: {
    // Finney Testnet
    finney: {
      url: "https://finney.uomi.ai",
      chainId: XXX,
      accounts: [privateKey],
    },
  }
};
```

**4. Deploy Your Contract**

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

### Truffle Setup

#### Prerequisites

Install the HD Wallet Provider:

```bash
npm install @truffle/hdwallet-provider
```

#### Configuration

Modify your `truffle-config.js`:

```javascript
const HDWalletProvider = require('@truffle/hdwallet-provider');
const { privateKey } = require('./private.json');

module.exports = {
  networks: {
    // Finney Testnet
    finney: {
      provider: () => new HDWalletProvider(
        privateKey,
        'https://finney.uomi.ai'
      ),
      network_id: XXX,
    },
  }
};
```

#### Deployment

Deploy to your chosen network:

```bash
truffle migrate --network finney
```

> 💡 **Note**\
> If no network is specified, Truffle will use the default development network.


---

# 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.uomi.ai/build/evm-smart-contracts/hardhat.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.
