# Setup Hardhat fork

#### Prerequisite:&#x20;

Install Docker for your platform:&#x20;

* [Mac](https://docs.docker.com/desktop/install/mac-install/)
* [Linux](https://docs.docker.com/desktop/install/windows-install/)
* [Windows](https://docs.docker.com/desktop/install/linux-install/)

#### Step 1: Select "Hardhat fork", give your fork a name, and press "Save"

{% hint style="info" %}
Give your fork a recognizable name to make your life easier later on, e.g. when looking for the fork in the list of chains to add contracts deployed on this fork. Especially if you deploy multiple forks, they should have distinguishable names
{% endhint %}

<figure><img src="/files/bzxB17BAmbkFOqSfVL9j" alt="" width="563"><figcaption></figcaption></figure>

#### Step 2: Click on "Setup Agent" to open your setup info guide&#x20;

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

#### Step 3: Get an API Key by clicking on "Create Key" in your setup agent guide

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

#### Step 4: Run the following command as prompted in the setup guide in your project, as your guide will include all the relevant variables as for example your API Key. Example here:

```

docker run \
    -e HARDHAT = true \
    -e SOURCE_NODE=https://eth-mainnet.g.alchemy.com/v2/URADvEwKh-zXgTuUQ \
    -e BLOCKTORCH_API_KEY=undefined \
    -e BLOCKTORCH_CHAIN_ID=c642d08d-ca7e-696-9477-0f9429dcf045 \
    -e BLOCKTORCH_PORJECT_ID=e19f3c34-1217-4df0-b2d6-6084411c0dd \
    -p=8000:8000 -p=8545:8545 \
    ghcr.io/blocktorch-xyz/blocktorch-agent:latest

```

#### Step 5: Add the fork to your project on your machine

```
{
    networks: {
        blocktorch: {
            url: http://127.0.0.1:8545/,
            accounts: [
                example_private_key
            ]
        }
    }
}
```

{% hint style="success" %}
Congratulations, you have successfully added your local hardhat fork to blocktorch 🥳\
If you now try to [add a smart contract](/concepts/data-sources/smart-contracts.md) to blocktorch that has been deployed on your local hardhat fork you can see your local hardhat fork in the list of available chains
{% endhint %}


---

# 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.blocktorch.xyz/concepts/data-sources/local-forks/setup-hardhat-fork.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.
