Introduction to hardhat-laika

Nonthakon Jitchiranant
Laika Labs
Published in
2 min readFeb 20, 2022

--

Hi, Buidlers! 🙌 In this article I want to introduce you to another great thing that we’ve been working on lately. It’s a Hardhat plugin called “hardhat-laika”

What is hardhat-laika ?

hardhat-laika is a Hardhat plugin that helps you sync your compiled contract with Laika. So you can make a request without having to write a single line of code.

And also, Boost your performance when working with Hardhat 💪

Let’s try it out!

First, you going to need to start a new Hardhat project.

npx hardhat init

Then, pick a configuration you like (I pick this specific configuration because I need Greeter.sol as an example contract so we could get going easily)

√ 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 setup is completed let’s install hardhat-laika

npm i hardhat-laika

Now, import it to your hardhat.config.js (By adding require(…) on the top)

Alright, now we’re all set. Let’s try to use it!

There are 2 ways to use hardhat-laika 1. using it through the command line and 2. using it through your own scripts (hardhat-laika define task is hre so you can use it easily)

Let’s try the first way.

  1. Command-Line way

First, Let’s compile our contract so we 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, I’ll use the command

npx hardhat laika-sync --contract Greeter --address 0x5FbDB2315678afecb367f032d93F642f64180aa

You should be able to see something like this.

laika-sync task

2. Script way

Let’s take a look at scripts/sample-script.js

I just have to simply add hre.run() to line 25 and we’ll all set! Let’s run it using the command.

npx hardhat run scripts/sample-script.js

You should be able to see something like this.

Alright! That’s it for today. Hope you find it useful 😃 See you next time!

Connect with us

Facebook: https://www.facebook.com/getlaikaapp/
Discord: https://discord.gg/4DzwHuxhcf
Twitter: https://twitter.com/getlaikaapp

--

--