Use hardhat-laika
What is hardhat-laika ?
hardhat-laika is Laika's own Hardhat plugin that helps you sync your compiled contracts with Laika. This enables you to make a request without having to write a single line of extra code.
In counterview, it also boosts your performance when developing with Hardhat! 💪
Let’s try it out!
First, we are going to start a new Hardhat project using
npx hardhat init
Then, pick a configuration you like (We'll be usingthis configuration and Greeter.sol as an example contract in this guiding example)
√ What do you want to do? · Create a basic sample project
√ Hardhat project root: · /path/to/project/
√ Do you want to add a .gitignore? (Y/n) · y
√ Do you want to install this sample project's dependencies with npm (...)? (Y/n) · y
After the project setup is completed, let’s install hardhat-laika by using
npm i hardhat-laika
Now, import it to your hardhat.config.js By adding a require(…) statement at the top
Alright, now we’re all set! Let’s try to use it!
There are two ways to use hardhat-laika, viz.
  1. 1.
    through the command line
  2. 2.
    through your own scripts (by defining a hardhat-laika task)
Let’s try the first way.
  1. 1.
    The Hardhat Runner CLI
First, Let’s compile our contract so we can get the ABIs.
npx hardhat compile
Then, use the laika-sync task to sync it to Laika
npx hardhat laika-sync --contract <contract_name> --address <OPTIONAL address_of_that_contract>
For this example, we'll use the command with the following parameters:
npx hardhat laika-sync --contract Greeter --address 0x5FbDB2315678afecb367f032d93F642f64180aa
You should be able to see something like this.
laika-sync task
2. Creating a Script
Let’s take a look at scripts/sample-script.js
We just have to simply add to line 25 and we’re set! We can run it using the command.
npx hardhat run scripts/sample-script.js
You should be able to see something like this.
Both methods enable you to directly integrate Laika with your Hardhat environment as shown.
Copy link