Deploy Your First Smart Contract with Hardhat: Beginner-Friendly Step-by-Step Guide

Table of contents
- TL;DR: How to Deploy Your First Smart Contract with Hardhat
- Hardhat vs Remix: Why Serious Solidity Developers Prefer Hardhat
- ๐ ๏ธ Hardhat System Requirements and Setup Guide
- Step 1: Install Hardhat and Set Up Your First Smart Contract Project
- Step 2: Writing Your First Contract in Hardhat
- Step 3: Deploy the Contract Locally
- Step 4: Interact With the Contract Using the Console
- Step 5: Write Tests for Your Smart Contract
- ๐งช 1. Create the Test File
- Step 6: Deploy to a Public Testnet With MetaMask (With No Confusion)
- Step 7: Verify Your Contract on Etherscan
- Step 8: Push Your Project to GitHub (Using GitHub Desktop)
- ๐ง Common Smart Contract Beginner Mistakes to Avoid
- What You Built
- What You Can Do Next
- Final Advice
After writing a few contracts in Remix, I knew it was time to move to something more powerful. Hardhat is a professional-grade development toolchain that makes writing, testing, and deploying Solidity smart contracts locally easy.
It keeps coming up in conversations among serious Solidity developers, and for good reason. But when I tried to get started, most setup tutorials either lacked real context or skipped critical steps.
I wrote this guide as I was figuring it out myself. If you're about to take that leap from browser-based development to a local environment and want someone to walk you through it slowly, this article is for you.
I'll explain exactly what each file and command does and how to go from zero to having a working smart contract locally on your machine, tested, and deployed.
Let's get started by creating your first local smart contract using Hardhat.
TL;DR: How to Deploy Your First Smart Contract with Hardhat
๐ง Install Node.js, VS Code, MetaMask
๐ฆ Scaffold your Hardhat project
โ๏ธ Write and compile a TipJar contract
๐งช Test it locally with Hardhat's console
๐ Deploy to Sepolia with MetaMask + Alchemy
๐ Verify it on Etherscan
๐ Push your repo to GitHub
โ From zero to deployed, this guide is designed for beginners and is fully aligned with real-world applications.
By the end, you will confidently deploy your first smart contract and be ready to take on new challenges!
Hardhat vs Remix: Why Serious Solidity Developers Prefer Hardhat
If you're reading this, I'm assuming you've either used Remix before or at least heard of it. Remix is excellent for experimenting with Solidity in the browser. Still, if you're building production-ready smart contracts, you'll quickly run into its limits when you want to:
Work on larger projects
Use version control (Git)
Write automated tests
Script your deployments
Collaborate as real developers do
That's where Hardhat comes in.๐กWhat is Hardhat? Hardhat is a local development environment for building, testing, and deploying Solidity smart contracts with professional workflows.Here's what Hardhat gives you that Remix doesn't:
๐งช Real Testing Support
In Hardhat, you can write automated tests in JavaScript or TypeScript to verify your contract logic.
Don't worry if this sounds new. We'll explain and write your first real tests later in the guide. This example shows what's possible.
Here's a simple example of a test case:
it("should accept ETH deposits", async function () {
await addr1.sendTransaction({
to: tipJar.target,
value: ethers.parseEther("0.01"),
});
const balance = await tipJar.getBalance();
expect(balance).to.equal(ethers.parseEther("0.01"));
});
โ This test sends 0.01 ETH to the contract and verifies that the balance is updated correctly. When you run your tests, you'll see a similar result later in this guide.
๐ Project Structure That Scales
Hardhat encourages an organized project structure with separate contracts, scripts, and test folders. This approach is beneficial as it helps you build with real development workflows in mind, not just for quick experiments. It also makes your project more scalable and easier to manage as it grows in complexity.
๐งฑ Scripted Deployments
Instead of relying on a UI to deploy, Hardhat encourages a more professional approach to scripts. These reusable, version-controlled scripts align with how professional teams manage contracts.
๐ Plugins and Integrations
Hardhat supports many tools, such as Ethers.js, OpenZeppelin, Tenderly, The Graph, and Chainlink. It's flexible, extendable, and widely used in real projects.
But here's the important thing:
I'll walk you through from absolute zero, including:
Installing the correct versions (so you don't get version mismatch errors)
Explaining what every command does
Breaking down what each file means and why it matters
You're in the right place if you've ever closed a Hardhat tutorial because it assumed too much.
๐ ๏ธ Hardhat System Requirements and Setup Guide
Before executing any commands, ensure your system is configured correctly. Skipping these steps may lead to frustrating errors later. Hereโs what you need and how to prepare everything.
๐ฅ๏ธ Your Terminal (Command Line)
๐ฅ๏ธ Your Terminal (Command Line)
The terminal is where you'll run every command during Solidity development. Whether you're on Mac, Windows, or Linux, you must get comfortable using it.
Mac: Use the built-in Terminal app.
Windows: Use Command Prompt, PowerShell, or Windows Terminal (recommended).
Linux: You already know your way around! ๐
โ Check that your terminal is responsive:
Open it and type this command:
echo Hello Hardhat
Your terminal will work fine if it prints Hello Hardhat back to you.
๐ป Node.js and npm
Hardhat runs on Node.js, so this part is not optional. You'll also install the necessary tools using npm (Node Package Manager).
โ Install Node.js:
Go to https://nodejs.org and download the LTS (Long-Term Support) version.
Avoid the "Current" version unless you know what you're doing, as it may cause compatibility issues.
๐ At the time of writing, the LTS versions are:
Node: v20.x.x
npm: v10.x.x
Hardhat supports Node.js versions from 18 to 22 and npm versions 8 and above.
โ Confirm installation:
Once installed, open your terminal and run:
node -v
npm -v
You should see version numbers like:
v22.16.0
10.9.2
If you see those, you're all set.
๐ง A Code Editor (I Recommend VS Code)
To write and manage your smart contracts, you'll need a code editor. Visual Studio Code is a great choice for beginners.
โ Download it: https://code.visualstudio.com
After installing, open VS Code and install the Solidity extension from the Extensions tab. This extension provides syntax highlighting, code suggestions, and error checking to make writing contracts easier.
๐ฆ MetaMask (For Testnet Deployment)
If you plan to deploy contracts to a public testnet like Goerli or Sepolia, you'll need MetaMask.
Here's what to do:
Install the MetaMask browser extension.
Set up your wallet.
Use a faucet to get free test ETH.
It's optional at this stage, but useful when ready to go live.
โ Take a breather
Once you've installed these tools, you're in a great spot. You've completed a critical part of the setup. When ready, we'll walk you through creating your first Hardhat project.
Step 1: Install Hardhat and Set Up Your First Smart Contract Project
Now that your Solidity environment is ready, let's begin the straightforward process of creating your first Hardhat-powered smart contract project. This step will establish a basic folder structure that includes everything you need to write, compile, and deploy smart contracts.
This process is designed to work seamlessly on Mac, Linux, and Windows (using PowerShell). If you follow along exactly, you'll have a functioning local Solidity development setup, regardless of your operating system.
โ ๏ธ Important: As of Hardhat v2.24.2 and later, you should initialize a project using npx hardhat init
. The older npx hardhat
method is deprecated and will be removed in future versions. This guide uses the updated approach.
๐ 1. Create a New Project Folder
Choose a folder on your machine to store your smart contracts and project files.
For Mac/Linux:
mkdir my-first-hardhat
cd my-first-hardhat
For Windows (PowerShell):
mkdir my-first-hardhat
cd my-first-hardhat
This creates a new folder and changes your working directory to it.
๐งฑ 2. Initialize a Node Project
Hardhat is installed as a dependency in a Node.js project, so we must create a package.json
file. Run the following command:
npm init -y
This sets up the project with default settings; you'll now have a package.json
file.
โ๏ธ 3. Install Hardhat
Next, install Hardhat locally by running:
npm install --save-dev hardhat
The --save-dev
flag marks it as a dev dependency only needed during development.
๐ 4. Initialize the Project with npx hardhat init
Now that Hardhat is installed, run:
npx hardhat init
This is the new and recommended way to scaffold a Hardhat project.
You'll see a menu like this:
โ 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
โ
Choose: Create a JavaScript project
Hereโs why weโre picking this option:
- JavaScript is beginner-friendly and widely used.
- It integrates smoothly with Hardhat's sample tests and deployment scripts.
- You wonโt have to worry about TypeScript configurations, types, or additional files.
Next, it will prompt you:
โ Project root: (your-folder-name)
โ Press Enter to use the current folder you are already in.
Then, youโll be asked:
Add a
.gitignore
โ YesInstall sample project dependencies โ Yes (hit "Y")
Hardhat will install:
ethers
hardhat-toolbox
Hardhat uses these main packages to deploy, test, and interact with Ethereum smart contracts. You might see some
npm WARN
messages or low-level vulnerabilities; this is normal and won't affect your ability to build. You can optionally runnpm audit fix
later if you wish.
๐ฆ What Youโll See in Your Project Folder
Once the setup is complete, you will find the following in your project folder:
Contracts/
: Where your Solidity files goTest/
: Where tests will be located.hardhat.config.js
: The configuration file for your project..gitignore
,README.md
, and a few other basic files.
โ You are now set up with a real Solidity development environment.
In the next step, we will replace the sample contract with your own and deploy it locally.
Step 2: Writing Your First Contract in Hardhat
At this point, you should have a working Hardhat project with some sample code. Let's delete that sample code and write our simple contract.
We will start by creating a contract that allows people to send ETH into a tip jar and lets the owner withdraw it later. This contract is beginner-friendly but still teaches essential concepts such as payable,
address,
require,
and state variables.
๐งน 1. Remove the Sample Contract
Hardhat generates a sample file called Greeter.sol
. To remove it, follow these steps:
Open your project folder in Visual Studio Code (VS Code):
Launch VS Code.
Go to File > Open Folder and select the my-first-hardhat folder.
Navigate to:
contracts/Greeter.sol
Delete the
Greeter.sol
file.
You may also want to delete the default test file:
test/sample-test.js
This will help you start fresh.
๐ 2. Create a New Solidity File
Inside the contracts/
folder, create a new file named TipJar.sol
. Paste the following code inside the file, which includes comments to help you understand each part:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18; // Tells Solidity which version you're using
contract TipJar {
address public owner; // Stores the address of the contract owner
constructor() {
owner = msg.sender; // Sets the deployer as the owner
}
// Allows the contract to receive ETH directly
receive() external payable {}
// Returns the balance held in the contract
function getBalance() public view returns (uint) {
return address(this).balance;
}
// Allows only the owner to withdraw all the ETH
function withdraw() public {
require(msg.sender == owner, "Only the owner can withdraw");
payable(owner).transfer(address(this).balance);
}
}
What this contract does:
Accepts ETH from anyone
Lets the owner withdraw funds
Shows how much ETH is stored
โ๏ธ 3. Compile Your Contract
Once you have written your contract, it's time to compile it so Hardhat can generate the necessary files for deployment and interaction.
Run the following command in your terminal:
npx hardhat compile
โ This command will:
Check your Solidity code for errors.
Compile it into bytecode and ABI(Application Binary Interface).
Save the output in the
artifacts/
folder.Store metadata in the
cache/
folder.
๐ Whatโs in the <artifacts/>
folder?
The artifacts/
folder contains the compiled versions of your smart contracts. For each .sol
file, you'll find a corresponding .json
file that includes:
ABI (Application Binary Interface): needed to interact with the contract.
Bytecode: what gets deployed to the blockchain.
Metadata: includes compiler version, settings, etc.
Hardhat uses these files during deployment, testing, and console use.
๐๏ธ Whatโs in the <cache/>
folder?
The cache/
folder helps Hardhat track what has already been compiled. If your contract hasn't changed, Hardhat can skip recompilation to save time.
You don't need to manually edit this folder โ it's managed internally by Hardhat.
โ Successful Output
If everything is working correctly, you should see a message like:
Compiled 1 Solidity file successfully
โ Before vs After:
Before: You had a blank
TipJar.sol
file.After compiling: You now have ABI, bytecode, and metadata in
artifacts/
.Your contract is ready for deployment.
๐ Congratulations!
You just wrote and compiled your first contract in Hardhat!
Once your contract is compiled, you can deploy it to a local Hardhat network and start interacting with it!
Step 3: Deploy the Contract Locally
Now that your contract is written and compiled, letโs deploy it to a local blockchain using Hardhatโs built-in network.
This wonโt cost real ETH or require MetaMask. It all runs on your machine.
๐งพ 1. Create a Deploy Script
Inside the scripts/
folder, create a new file named deploy.js
.
Paste the following code into it:
const hre = require("hardhat");
async function main() {
const TipJar = await hre.ethers.getContractFactory("TipJar");
// Deploy the contract
const tipJar = await TipJar.deploy();
// Wait for the deployment transaction to be mined
await tipJar.waitForDeployment();
console.log(`Contract deployed to: ${tipJar.target}`);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
โ This script:
Compiles your contract if needed
Deploys it to the local Hardhat blockchain
Logs the contract address
๐งช 2. Run a Local Node + Deploy
In your terminal, use this command:
npx hardhat run scripts/deploy.js
You should see output like:
Contract deployed to: 0xYourContractAddressHere
Thatโs it! Your contract is now deployed locally. No wallet, no gas, no real blockchain needed.
Next, weโll show you how to interact with your deployed contract using the console.
Step 4: Interact With the Contract Using the Console
Now that your contract is deployed locally, let's interact with it using Hardhat's built-in JavaScript console.
This lets you test and call your contractโs functions directly, without needing a front-end or UI.
๐ฅ๏ธ 1. Start the Local Hardhat Network
In your terminal, run:
npx hardhat node
This will:
Start a local Ethereum blockchain at
http://127.0.0.1:8545
Create 20 test accounts with ETH
Keep running as a background blockchain for testing
๐กLeave this terminal window running. Do not close it.
To open a second terminal:
Mac: Press
Cmd + T
in Terminal or open a new windowWindows (PowerShell or Terminal): Press
Ctrl + Shift + T
or click the dropdown arrow โ "New Tab"Linux: Press
Ctrl + Shift + T
๐ 2. Deploy to the Local Node (Not In-Memory)
In the second terminal, go to your project folder again:
cd path/to/your/my-first-hardhat
Then run this command to deploy your contract to the running node:
npx hardhat run scripts/deploy.js --network localhost
Youโll see output like:
Contract deployed to: 0xYourContractAddressHere
โ Copy this address โ weโll use it in the next step.
๐ฌ 3. Open the Hardhat Console
Still in your second terminal, run:
npx hardhat console --network localhost
This opens an interactive JavaScript console connected to your local blockchain.
๐งช 4. Interact With Your Deployed Contract
Now letโs load the contract inside the console. Paste and run each line one at a time, pressing Enter after each line.
undefined
, thatโs normalโit just means the console didnโt print a return value. The command still worked.const tipJarFactory = await ethers.getContractFactory("TipJar")
Youโll likely see:
undefined
Check if it worked by running:
tipJarFactory
This should return a ContractFactory
object.
Attach to the deployed contract:
const tipJar = await tipJarFactory.attach("0xYourContractAddressHere")
Replace the address with your actual deployed address.
Confirm it's loaded:
tipJar.target
This should return the address again.
โ Now test your contract:
Check the balance:
await tipJar.getBalance()
Youโll get:
0n
That n
means the value is a BigInt. Solidity values in ethers.js v6+ come as BigInts, not regular numbers.
Send a tip:
const [signer] = await ethers.getSigners()
await signer.sendTransaction({
to: tipJar.target,
value: ethers.parseEther("0.01")
})
Check the balance again:
await tipJar.getBalance()
Youโll see:
10000000000000000n
Which is 0.01 ETH in wei.
Withdraw as the owner:
await tipJar.withdraw()
Youโll see a long ContractTransactionResponse
object confirming the transaction was successful.
โ You've now:
- Simulated tipping
- Checked the on-chain balance
- Withdrawn ETH โ all locally, with no wallet required!
Step 5: Write Tests for Your Smart Contract
If you were building a car, would you drive it at 200 km/h without testing the brakes? Exactly.
Smart contracts handle real money. Once deployed, they're immutable, meaning one bug could cost you or your users thousands.
Testing helps you:
Catch logic errors before they go live
Simulate how your contract behaves with real transactions
Gain confidence that your code is solid
Let's write a basic test for your TipJar contract to check two core behaviors:
It accepts tips
It allows the owner to withdraw
๐งช 1. Create the Test File
In your Hardhat project, go to the test/
folder and create:
test/tipjar-test.js
โ๏ธ 2. Add This Code (With Comments)
// Load Chai for assertions and Hardhat's ethers for contract interaction
const { expect } = require("chai")
const { ethers } = require("hardhat")
// Group our TipJar tests together
describe("TipJar", function () {
let TipJar, tipJar, owner, addr1
// This runs before each test to deploy a fresh contract
beforeEach(async function () {
TipJar = await ethers.getContractFactory("TipJar") // Load the contract factory
;[owner, addr1] = await ethers.getSigners() // Get two test accounts
tipJar = await TipJar.deploy() // Deploy a new contract
await tipJar.waitForDeployment() // Wait for full deployment
})
// โ
Test: Can people send ETH to the contract?
it("should accept ETH deposits", async function () {
await addr1.sendTransaction({
to: tipJar.target, // Send 0.01 ETH to the TipJar contract
value: ethers.parseEther("0.01"),
})
const balance = await tipJar.getBalance() // Call the getBalance() function
expect(balance).to.equal(ethers.parseEther("0.01"))
})
// โ
Test: Can the owner withdraw funds?
it("should allow owner to withdraw", async function () {
// First, send 0.01 ETH to the contract
await addr1.sendTransaction({
to: tipJar.target,
value: ethers.parseEther("0.01"),
})
await tipJar.withdraw() // Owner calls withdraw()
const balance = await tipJar.getBalance()
expect(balance).to.equal(0n) // Balance should be 0
})
})
๐งช 3. Run the Tests
๐จ Important: If you're still inside the Hardhat console (from the second terminal where you interacted with the contract), exit it first:
.exit
Then, hit Enter to return to your standard terminal prompt.
Now, from your project directory (still in that terminal), run your tests:
npx hardhat test
You should see something like:
TipJar
โ should accept ETH deposits
โ should allow owner to withdraw
โ Thatโs it! Youโve tested your first real smart contract.
Step 6: Deploy to a Public Testnet With MetaMask (With No Confusion)
So far, you've deployed and tested your contract locally.
Great job! Now it's time to put it somewhere others can see it, like the Sepolia testnet, using MetaMask, Alchemy, and Hardhat.
๐ Prerequisites
Before deploying to Sepolia, you must gather some essential tools and details. Think of this as preparing your passport, ticket, and wallet before boarding a flight. Once all of this is ready, your deployment will be smooth.
๐งน What You Need to Deploy to a Public Testnet With MetaMask
MetaMask extension installed in your browser โ Get it here
A MetaMask wallet was created earlier(save your secret phrase securely)
A Sepolia wallet address in MetaMask (select Sepolia network)
A free Alchemy account โ Sign up at alchemy.com
๐กWhere to Find Your Metamask Private Key
To deploy your project, you need the private key from the specific MetaMask account youโll be using. Please note that this differs from your Secret Recovery Phrase; it is the individual account's private key.
Click the MetaMask extension icon in your browser toolbar.
Select the account (ensure Sepolia is selected).
Click the three dots โ Account details โ Export Private Key.
Enter your MetaMask password to reveal the key.
Copy the private key (keep it safe!).
.env
file. Please doย notย share it or commit it to GitHub.๐ง Where to Get Your Sepolia RPC URL in Alchemy
Go to the Alchemy Dashboard
Click Create App
Name it e.g.
hardhat-sepolia
Choose Ethereum as the chain.
After creation, select Sepolia Network โ Copy the Network URL
Example:
https://eth-sepolia.g.alchemy.com/v2/YourApiKeyHere
๐ธ How to Get Free Sepolia ETH (No Mainnet Required)
Use the Google Cloud Faucet to avoid mainnet ETH requirements:
Paste your MetaMask extension Sepolia address
Complete CAPTCHA
Receive 0.5 Sepolia ETH instantly
๐ Deployment Guide to Deploy to a Public Testnet With MetaMask
Now that your environment is ready, you're about to deploy your contract to a live blockchain environment with which others can see and interact.
๐ ๏ธ 1. Install dotenv
Before connecting to Sepolia, we need a way to safely store and load your private key and RPC URL inside the project. This is where the dotenv
package comes in. It lets you keep sensitive info in a separate file so you don't hardcode anything sensitive into your scripts.
npm install dotenv
๐ 2. Create a .env
File
In your project root, create .env
:
PRIVATE_KEY=your_metamask_private_key_here
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YourApiKeyHere
.env
to .gitignore
to keep secrets safe out of version control.โ๏ธ 3. Update hardhat.config.js
Replace the contents with:
// hardhat.config.js
// 1. Load environment variables
require("dotenv").config();
// 2. Load the Hardhat Toolbox plugin (injects hre.ethers, tests, etc.)
require("@nomicfoundation/hardhat-toolbox");
const { PRIVATE_KEY, SEPOLIA_RPC_URL } = process.env;
module.exports = {
solidity: "0.8.21",
networks: {
sepolia: {
url: SEPOLIA_RPC_URL, // comes from .env
accounts: [PRIVATE_KEY], // comes from .env
},
},
etherscan: {
apiKey: "", // Optional: leave blank or set via env
},
};
This configuration ensures Hardhat knows how to connect to Sepolia using the credentials and endpoint stored in your .env
file.
๐ 4. Update scripts/deploy.js
// scripts/deploy.js
const hre = require("hardhat");
async function main() {
// Get the contract factory
const TipJar = await hre.ethers.getContractFactory("TipJar");
// Deploy the contract
const tipJar = await TipJar.deploy();
// Wait for deployment to be confirmed (Ethers v6+ method)
await tipJar.waitForDeployment();
// Log the deployed contract address
console.log("โ
TipJar deployed to:", tipJar.target);
}
main().catch((error) => {
console.error("โ Deployment error:", error);
process.exit(1);
});
This is a basic deployment script. You can reuse this pattern for other contracts by updating the name passed to getContractFactory
.
๐ 5. Deploy to Sepolia
npx hardhat clean
npx hardhat compile
npx hardhat run scripts/deploy.js --network sepolia
Expected output:
Downloading compiler...
Compiled successfully
โ
TipJar deployed to: 0xYourDeployedAddressHere
Double-check your values, network name, and script path if you encounter any errors.
๐ Your contract is now live on Sepolia! View mine on Sepolia Etherscan.
Step 7: Verify Your Contract on Etherscan
Verifying your contract source code on Etherscan adds trust and transparency. Others can read your code, see comments, and confirm your contractโs behavior.
1. Get an Etherscan API Key
Log in to Etherscan and navigate to the API Dashboard.
Click Add in API Key Section, name it (e.g.,
TipJarSepolia
), and click Create.Copy the generated API key.
2. Store the Key in .env
Open your .env
file and add:
ETHERSCAN_API_KEY=YourEtherscanApiKeyHere
.env
is in .gitignore
to keep your key private.3. Configure hardhat.config.js
Ensure you have the Hardhat Toolbox plugin loaded:
require("dotenv").config()
require("@nomicfoundation/hardhat-toolbox")
Then add or update the etherscan
section:
module.exports = {
solidity: "0.8.21",
networks: { /* ... */ },
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
}
4. Run the Verification Task
In your terminal, run:
npx hardhat verify --network sepolia <DEPLOYED_CONTRACT_ADDRESS>
Replace <DEPLOYED_CONTRACT_ADDRESS>
with your actual address.
5. View Your Example
You can see the verified source for our demo here:
Awesome! Your contract is now verified; you have a working example to reference.
Step 8: Push Your Project to GitHub (Using GitHub Desktop)
Git on the command line can be tricky at first. If you prefer a graphical interface, GitHub Desktop pushes your project to GitHub as easily as a few clicks.
๐งฉ What You Need
GitHub Desktop installed โ Download here
GitHub account โ if you havenโt already, sign up at github.com
๐ฆ 1. Open Your Project in GitHub Desktop
Launch GitHub Desktop.
Click File โ Add Local Repositoryโฆ
Browse to your project folder and click Add Repository.
โ๏ธ 2. Create a .gitignore
File (Once Only)
If you havenโt already, add a .gitignore
in your project root with:
node_modules/
.env
cache/
artifacts/
This prevents unnecessary or sensitive files from being pushed.
๐ 3. Commit Your Changes
In GitHub Desktop, youโll see all uncommitted changes.
In the Summary box, type
Initial commit: Hardhat TipJar project
.Click Commit to main.
๐ 4. Publish Repository to GitHub
Click Publish repository in the top toolbar.
Name the repo
hardhat-tipjar
(or customize). Add a description (optional), and set it to Public.Click Publish Repository.
๐ 5. Verify on GitHub
Navigate to your GitHub profile or directly to the repository URL
Youโll see your files, commit history, and have a link you can share with others.
Next, now that your code is on GitHub, anyone can clone or fork it to get started quickly. Feel free to explore more GitHub Desktop features like branching, merging, and pull requests!
๐ง Common Smart Contract Beginner Mistakes to Avoid
These are mistakes I made, so you donโt have to. Learn from them to avoid painful debugging sessions and wasted time.
โ Skipping Node.js setup
Always install the Long-Term Support (LTS) version of Node.js and verify it's installed with:
node -v
npm -v
โ Using the wrong Hardhat init command
Use:
npx hardhat init
Avoid using:
npx hardhat
Which runs the interactive prompt, but does not initialize a project properly in every case.
โ Forgetting to ignore .env files
Never commit your .env
file. Add it to .gitignore
immediately:
.env
This file contains sensitive keys and should never be pushed to version control.
โ Deploying without starting a local node
When deploying locally, always begin the local blockchain first:
npx hardhat node
Otherwise, your deployment will fail to connect to any running chain.
โ Rushing past errors
When errors appear, take your time reading the stack trace and messages carefully. Often, the solution is already hinted at in the log.
What You Built
You made it. Not only did you follow through, but you also built something real.
Here's a recap of what you accomplished:
โ Wrote your first Solidity smart contract (
TipJar
)โ Tested it locally using Hardhat's development environment
โ Deployed it to the Sepolia public testnet with MetaMask and Alchemy
โ Used environment variables to keep sensitive data safe
โ (Optional) Verified the source code on Etherscan
โ Published your project to GitHub for others to see
What You Can Do Next
This project is your launchpad. From here, you can:
Expand the contract (add tipping limits, events, or withdrawal logic)
Connect your contract to a frontend using HTML/JavaScript or React
Explore Hardhat plugins for testing, deployment, and verification
Build more advanced projects like:
Multi-send wallets
Voting dApps
NFT collections
Final Advice
Keep this project saved. It's your Web3 "Hello, world."
Donโt be afraid to tweak, break, and fix it. Thatโs how you grow.
Start putting your work out there:
Push to GitHub
Write blog posts
Share on X (Twitter) or LinkedIn
Your goal might be to freelance, land a job, or launch your dApp. Whatever it is, the most important thing is that youโve built and finished something real. Thatโs how confidence and momentum begin. That puts you ahead of most.
Let's keep building. โจ
Star the GitHub repo.
Subscribe for more web3 walkthroughs.
Subscribe to my newsletter
Read articles from Peace Aisosa Osarenren directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
