Run squids with Ganache or Hardhat
Objective
Here we show how it is possible to index an Ethereum development node running locally. This is useful for those who want to start developing a squid ETL or API in a local environment without waiting for the contract to be deployed to a testnet.Pre-requisites
Setup
In this tutorial we will be using a layout in which the squid and the Hardhat/Ganache setup share the same folder. Create a new squid by running:ethereum-local-indexing is the project name and evm refers to the evm template.
Install the dependencies and update evm-processor and typeorm-store to their ArrowSquid versions:
If you chose Hardhat {#hardhat}
Install the package.1. Create project
In a terminal, navigate to the squid project root folder. Prepare it by runningtsconfig.json provided by Hardhat:
2. Configure Hardhat automining
Then, open thehardhat.config.ts and replace the HardhatUserConfig object with this one:
mining configuration will continuously mine blocks, even if no events or transactions are executed. This can be useful for debugging. You can read more about it on hardhat official documentation.
3. Sample contract
There should be acontracts subfolder in the project folder now, with a sample contract named Lock.sol. To compile this contract and verify its correctness, run
artifacts/contracts/Lock.sol/Lock.json. We will use this file in squid development.
4. Launch hardhat node
From the project root folder, run5. Deploy the contract
The node will keep the console window busy. In a different terminal, run this command:If you chose Ganache {#ganache}
Install Truffle and Ganache packages.1. Truffle project, sample contract
Let’s create a new truffle project with a sample contract. In the project main folder runbuild/contracts/MetaCoin.json. It will be useful for indexing.
2. Create a workspace
Launch the Ganache tool and select the New Workspace (Ethereum) option. ) Next, provide a name for the workspace and link the Truffle project we just created to it. To do that, click Add project and select thetruffle-config.js file in the project root folder. Finally, select the Server tab at the top.
)
In this window, change the server configuration to the exact values reported in this image.
)
The AUTOMINE option is disabled to ease the debugging.
Finally, click “Start” to launch the blockchain emulator.
3. Deploy a smart contract
Configure Truffle by uncommenting thedevelopment section in truffle-config.js and setting its properties as follows:
Squid development
The indexing setup is ready to use. To test it, replace the contents ofsrc/processor.ts with the following.

