Set up a development environment for Etherlink
Etherlink is 100% compatible with Ethereum technology, which means that you can use any Ethereum-compatible tool for development, including Hardhat, Foundry, Truffle Suite, and Remix IDE. For more information on tools that work with Etherlink, see Developer toolkits in the Etherlink documentation.
In this tutorial, you use Hardhat to manage development tasks such as compiling and testing smart contracts. You also use Viem, which is a lightweight, type-safe Ethereum library for JavaScript/TypeScript. It provides low-level, efficient blockchain interactions with minimal abstraction.
-
Install Node.JS version 22 or later, which is required for Hardhat.
-
Initialize an Node project with NPM in a fresh directory:
npm init -y
npm install -D typescript @types/node ts-node chai @types/chai -
Install Hardhat and initialize it:
npm install -D hardhat
npx hardhat --init -
Follow these steps in the Hardhat prompts:
-
In the Hardhat prompts, select version 3 of Hardhat and
.as the relative path to the project. -
In the prompt for the type of project to create, select
A TypeScript Hardhat project using Node Test Runner and Viem. -
Select
trueorYto convert the project'spackage.jsonfile to ESM. -
At the prompt to install dependencies, select
trueorY. -
If Hardhat prompts you to update TypeScript dependencies, select
trueorY.
-
-
Install
@openzeppelin/contractsto use the Math library for safe calculations:npm i @openzeppelin/contracts -
Install dev libraries for verifying your smart contract:
npm i -D @nomicfoundation/hardhat-verifyVerify is a feature that verifies contracts on an Ethereum block explorer by checking the compiled code against the source code. Verifying your contracts provides source code transparency and a source reference for some tools to generate utility code.
-
(Optional) If you are using VsCode for development, install the Hardhat/Solidity plugin from Nomic: Solidity plugin for VsCode