Rootstock Hardhat Ignition Starter Kit
This guide provides a step-by-step approach to deploying smart contracts on the Rootstock using Hardhat Ignition.
While standard Hardhat guides cover general Rootstock development, this guide specifically showcases how Hardhat Ignition can make deployment more efficient by enabling programmatic and declarative approaches tailored for Rootstock.
Hardhat Ignition streamlines smart contract deployment by enabling programmatic definition, testing, and execution of deployment plans. This declarative approach significantly improves efficiency and manageability, making the deployment process smoother and more predictable.
With Ignition, you can easily manage complex deployment workflows, handle dependencies between contracts, and ensure smooth deployment processes.
Don’t worry if you’re new to this—every step will be explained in simple terms, making it accessible even if you’re just starting out.
What You'll Learn
- Set up a project to deploy smart contracts on Rootstock.
- Understand the project structure.
- Deploy a contract to the Rootstock Testnet using Hardhat Ignition.
What You Need Before Starting
-
Node.js
- This is a tool developers use to run JavaScript code.
- Download Node.js here. Install the LTS version (the one marked as “Recommended for Most Users”).
-
npm or Yarn
- These are tools that help manage project dependencies (software libraries your project needs to work).
- If you installed Node.js, you already have npm installed. You can check by typing this in your terminal:
npm -v
-
Hardhat
- A tool that helps developers create and test Ethereum-like projects (Rootstock is Ethereum-compatible).
-
Hardhat Ignition
- A plugin that makes deploying smart contracts easier.
-
Rootstock RPC API endpoint
- This is like an access point that connects your computer to the Rootstock blockchain. You can use the Testnet (for testing) or Mainnet (for real transactions).
- If you find the
deployments
andartifacts
folder inside the ignition directory, delete it.
Getting Started
Clone the Repository
Open your terminal (Command Prompt, PowerShell, or any terminal you like) And type this command.
git clone https://github.com/rsksmart/rootstock-hardhat-ignition-starterkit.git
cd rootstock-hardhat-ignition-starterkit
Open this folder in an IDE like Visual Studio Code.
Install Dependencies
In your terminal, run this command:
npm install
This will download and set up everything the project needs.
Understand the Project Structure
Once you’ve set up everything, your project files will look like this:
.
├── contracts # Your smart contracts live here.
├── ignition
│ └── modules # Deployment scripts for your contracts.
├── test # Files to test your smart contracts.
├── package.json # Lists project dependencies (like a grocery list for software).
├── hardhat.config.ts # Configuration for Hardhat.
├── README.md # A file explaining your project.
└── tsconfig.json # Configuration for TypeScript.
Modules Folder
The Modules folder contains essential scripts used for the deployment of smart contracts. Specifically, it includes two main files: Box.ts
and Lock.ts
.