# Testing with Hardhat

**Before you begin, please make sure to** [**create your StealthTest environment**](https://app.nameless.io/login) **and have access to the RPC URL and chain ID.**&#x20;

This document is intended to act as a quick start integration guide for new Hardhat projects. If you already have an established Hardhat project, skip to step 3.

For more information on Hardhat please access the documentation here: [Hardhat documentation](https://hardhat.org/hardhat-runner/docs/getting-started)

{% hint style="danger" %}
**We will never ask you for your private key, nor will it ever be required at&#x20;*****any*****&#x20;step in the process of creating a StealthTest environment.**
{% endhint %}

1. **Create a new Hardhat project.**

   1. `npm init -y`
   2. `npm install --save-dev hardhat`
   3. `npx hardhat`
   4. You will be provided with a default project containing: a smart contract, tests, and a deploy script.

   <figure><img src="/files/2zihKlp5HfGXdHJ8RUV1" alt=""><figcaption><p><em>Here is what you will see when creating your project</em></p></figcaption></figure>
2. **Compile your contracts**
   1. Contracts are located at `./contracts`
   2. `npx hardhat compile`
3. **Configure your Hardhat project for StealthTest**
   1. Within your `hardhat.config.js`
   2. Add an object called `networks`
   3. Inside that object, create an entry for `stealthtest`
   4. Add the `url`, `chainId`, and a list of `accounts` private keys you would like to use.
      1. **Note:** Each StealthTest environment comes with 5 pre-funded wallets, but please **never use these on mainnet**. You may also quickly fund your own wallet with our [Faucet](/features-and-fundamentals/faucet.md) but please **never share your private key with us or anyone you don't know.**&#x20;
   5. As an option, you can add `stealthtest` as your `defaultNetwork` so it will always be used.

:brain: **Example** `hardhat.config.js`&#x20;

```javascript
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.18",
  defaultNetwork: "stealthtest",
  networks: {
    stealthtest: {
      url: "https://5937ec2d-1c79-41b8-a5d1-c288e0e2efc7.ethereum.staging-42.nameless.io",
      chainId: 148073,
      accounts: ["0xf5d82a795ec5c5751161334378841e7a765182a047ee071bdfb1184f67b78d76"],
    },
  },
};

```

4. **Deploy your contracts**
   1. `npx hardhat run scripts/deploy.js`
   2. `stealthtest` is your `defaultNetwork`, so your deployment(s) will be sent there

### And that's it! You're now testing in private using StealthTest! :muscle:


---

# 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.stealthtest.com/stealthtest-guides/testing-with-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.
