Setup Hardhat fork

Prerequisite:

Install Docker for your platform:

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

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

Step 2: Click on "Setup Agent" to open your setup info guide

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

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
            ]
        }
    }
}

Congratulations, you have successfully added your local hardhat fork to blocktorch 🥳 If you now try to add a smart contract to blocktorch that has been deployed on your local hardhat fork you can see your local hardhat fork in the list of available chains

Last updated