Setup Hardhat
Hardhat is a development environment for Ethereum software. It helps developers compile, deploy, test, and debug their Ethereum applications. This guide will help you set up Hardhat for developing on SKALE.Prerequisites
- Node.js (v16 or higher) installed
- npm or yarn package manager
- Basic knowledge of JavaScript/TypeScript
Step 1: Create a New Project
Create a new directory and initialize a Node.js project:Step 2: Install Hardhat
Install Hardhat and its dependencies:The
@nomicfoundation/hardhat-toolbox package includes all commonly used plugins and tools for Hardhat development.Step 3: Initialize Hardhat
Initialize a Hardhat project:Step 4: Configure Hardhat for SKALE
Update yourhardhat.config.js (or hardhat.config.ts) file:
Replace the RPC URLs with your specific SKALE Chain endpoint. You can find SKALE Chain endpoints in the SKALE Portal.
Step 5: Install OpenZeppelin Contracts
Install OpenZeppelin Contracts:Step 6: Create Environment File
Create a.env file in your project root:
hardhat.config.js to load environment variables:
Step 7: Create a Deployment Script
Create a deployment script inscripts/deploy.js. Run:
Step 8: Compile Contracts
Compile your contracts:Step 9: Run Tests
Run your tests:SKALE-Specific Considerations
When deploying to SKALE with Hardhat:- Transaction Type: Hardhat automatically handles transaction types, but ensure your Hardhat version supports legacy transactions if needed
-
Gas Configuration: SKALE has zero gas fees, but you still need sFUEL for transactions:
-
Contract Verification: Verify contracts using Hardhat’s verify plugin:
