Hardhat is a development environment for Ethereum that allows you to edit, compile, debug and deploy your smart contracts and dApps. The main use of this tool is automatic deployment and unit test execution, similar to Truffle. For this toolbox, we have created a custom Javascript Provider and Typescript Provider, in order to work with the LACChain Networks orchestrated by LACNet.


First, let’s install hardhat.

					npm install --save-dev hardhat
npx hardhat

Now your can create your project folder, which you can name MyDapp.

					mkdir MyDapp
cd MyDapp

Contract Compilation

Before anything else, let’s create a very simple smart contract named Greeter.sol and store it in the contracts folder. All smart contracts you create should be stored there. 



					//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "hardhat/console.sol";

contract Greeter {
    string private greeting;

    constructor(string memory _greeting) {
        console.log("Deploying a Greeter with greeting:", _greeting);
        greeting = _greeting;

    function greet() public view returns (string memory) {
        return greeting;

    function setGreeting(string memory _greeting) public {
        console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
        greeting = _greeting;

To compile the smart contract, execute the command:

					npx hardhat compile

Hardhat Configuration

First, we need to extends the Hardhat Runtime Environment (HRE), by importing the corresponding extender in the hardhat.config.js:

					import "./extender";


This will include a lacchain property to the HRE.

To show the accounts defined in the config, use:

					task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
    const accounts = await hre.lacchain.getSigners();
    for (const account of accounts) {

Now, you need to define the nodeAddress and expiration parameters that will be sent in every transaction to the node in the hardhat.config.js file. For example:

   "lacchain": {
      "url": "",
      "nodeAddress": "0xd00e6624a73f88b39f82ab34e8bf2b4d226fd768",
      "expiration": 1736394529,
      "gasPrice": 0,
      "privateKeys": [

Deploy contract & interact

1. In the test file include the lacchain deployContract function as follows:

					import { lacchain } from "hardhat";

2. In your test case use the function as follows:

					const accounts = lacchain.getSigners();
const Greeter = await ethers.getContractFactory("Greeter", accounts[0]);
const greeter = await lacchain.deployContract(Greeter, "Hello, world!");

3. Now you will be able to call functions to the greeter smart contract as usual:

					expect(await greeter.greet()).to.equal("Hello, world!");

Copyright 2022 © All rights Reserved. Designed by LACNet