Skip to main content

Using Hardhat

Streamlining Smart Contract Development on Ruby L2 with Hardhat

This document outlines how we streamline smart contract development for the Ruby L2 Ethereum Virtual Machine (EVM) environment. By leveraging Hardhat, a comprehensive Ethereum development framework, we can establish a robust and efficient workflow for building decentralized applications (dApps) on Ruby L2.

Hardhat is a potent development environment designed to empower developers in the Ethereum ecosystem. It offers a comprehensive suite of tools. These functionalities, combined with Hardhat's streamlined workflow, make it an ideal choice for pioneering dApp development on Ruby L2.

Creating a Hardhat Project

  1. Create a directory for your project:
mkdir hardhat && cd hardhat
  1. Initialize the project, which will create a package.json file
npm init -y
  1. Install Hardhat
npm install hardhat
  1. Create a project
$ npx hardhat init

👷 Welcome to Hardhat v2.22.3 👷‍

? What do you want to do? …
Create a JavaScript project
Create a TypeScript project
Create a TypeScript project (with Viem)
❯ Create an empty hardhat.config.js
Quit

Get Ruby L2 Testnet Token

Acquiring testnet tokens is imperative to facilitate development on the Ruby L2 Testnet. Thankfully, a dedicated faucet is readily available at https://l2ruby-faucet.rubydevspace.com

The faucet is set to dispense 1 ETH per request, with a limit of one request every 24 hours. This ensures a fair distribution of resources and encourages efficient use of your time.

Deploy to Ruby L2 Testnet

When Hardhat is run, it searches for the closest hardhat.config.js file starting from the current working directory. This file normally lives in the Ruby of your project and an empty hardhat.config.js is enough for Hardhat to work. The entirety of your setup is contained in this file.

Add Ruby L2 Testnet to your hardhat.config.js

l2ruby: {
url: `https://l2ruby-testnet.rubydevspace.com`,
chainId: 904,
accounts: [YOUR_PRIVATE_KEY]
}

Deploy:

npx hardhat run scripts/deploy.js --network l2ruby