Introduction
Do you want to test your Ethereum smart contracts without having to worry about running out of ethers? We'll show you how to add as many free Ethers as you like to your Metamask wallet in this guide. By using this technique, you can have a plentiful supply of ethers available for use in testing and development. You only need NodeJs, the Chrome extension for Metamask, and a few easy steps.
Don't miss out on valuable insights into the world of Web3 development! By subscribing to my channel, you'll have access to a wide range of educational videos that can help take your skills to the next level. And if you're interested in connecting with me personally, be sure to check out the books, courses, and services I offer. Join me on this exciting journey of Web3 development and let's unlock its full potential together!
Prerequisites
To follow this tutorial and load free ethers into your Metamask, you will need the following packages:
You can watch the video tutorial with the YouTube video below.
Now let’s take a look at the steps and methods you will need to load unlimited free ethers to your Metamask wallet.
Hardhat Method
Because of its flexibility, extensibility, and speed, many web3 developers and web3 professionals alike have adopted Hardhat as the go-to framework for developing applications on the Ethereum network.
Here are the steps to load Ethers to Metamask using Hardhat.
STEP 1: Setting Up Project Structure
Create a project named **freeTestEthers**
, this could be any JavaScript-based project such as NodeJs, ReactJs, VueJs, or even a NextJs project. For this example, we will do a NodeJs project.
Next, open the project folder on the terminal or simply navigate to that directory and run the following commands.
cd freeTestEthers
npm init --y
The above command will initiate the folder as a nodeJs project. See the image below.
STEP 2: Creating Hardhat Project
Install the Hardhat packages that enable you to run a blockchain server, on the terminal, run the following commands:
npm install hardhat
After the installation, run the hardhat command below.
npx hardhat
Now, follow the promptings as can be seen in the image below to complete the installation:
STEP 3: Running Hardhat Server
On completion of the installation, again run this command to spin up the Hardhat blockchain server:
npx hardhat node
The above command should spin up a server looking like the one in the image above. Please observe the difference between the accounts and their private keys. We will later use the private keys to import Ethers to Metamask.
STEP 4: Accessing Metamask
With Metamask already installed, open your browser and visit the following link which will open up your Metamask extension interface in full. It should look like the image below.
chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#
STEP 5: Configuring Network
We are now to tell Metamask to use the Hardhat server running on step 3 of this section. Metamask normally comes with a Localhost network by default which has Hardhat configured, so we wouldn’t need to set up the network from scratch.
Head to the networks page of Metamask and ensure that your setup is on the same page as mine.
Did you notice the network configuration in the image above?
- Network Name: Refers to the alias you prefer giving to your blockchain network.
- New RPC URL: Points to the HTTP endpoint where the blockchain service can be accessed from, it comprises the host and port of the blockchain server.
- Chain Id: Specifies a unique identification number for a particular blockchain network, for the Hardhat server, it is always 31337.
- Currency Symbol: Indicates the kind of cryptocurrency used in a particular blockchain network.
STEP 6: Importing Accounts
From step 3, copy the first private key for the account zero (0) as can be seen in the following image.
Now, ensure that you select Localhost as your preferred network and click on the “import account” button as can be seen in the image below.
Congratulations, you have been able to import a new account using its private key, now compare how through the private key account 5 address is the same as the one in the image below.
You can now repeat this process to import more accounts from your Hardhat server.
With this one-time process implemented, anytime you spin up your Hardhat blockchain server, your account will be updated with a fresh 10,000 ETH balance. You can now use all these Ethers for your Hardhat development processes.
Take the first step towards becoming a highly sought-after smart contract developer by enrolling in my courses on NFTs Minting and Marketplace. Enroll now and let's embark on this exciting journey together!
Ganache Method
Truffle is one of the most comprehensive suites of tools for smart contract development. For a blockchain server, they have Ganache.
With Ganache you don’t need to install it on a specific project, you just need to set it up globally one time on your Local machine. Here are the steps to load Ethers to Metamask using Ganache.
STEP 1: Installing Ganache Server
To Install Ganache globally on your machine, run the following command on your terminal:
npm install ganache --global //or
sudo npm install ganache --global
After the installation, you should see a result similar to the image below.
STEP 2: Running Ganache Server
On completion of the installation, run the command below to spin up the Ganache blockchain server:
ganache -d
A server that resembles the one in the image above should be created using the aforementioned command. Please pay attention to how the accounts and their private keys differ. The private keys will eventually be used to import Ethers into Metamask just as we did with Hardhat.
STEP 3: Configuring Network
Once more, we must instruct Metamask to connect to the Ganache server that is active in this section's step 3. This time, a brand-new network will be added from scratch.
Verify that your configuration is on the same page as mine on Metamask's networks page.
Now it should be known that the only difference between Hardhat and Ganache servers is their chain Id. While Hardhat has a 31337 chain id, Ganache has 1337. Ensure that you click the save button to add it to your network list.
STEP 4: Importing Accounts
From step 3, copy the first private key for the account zero (0) as can be seen in the following image.
Now, ensure that you select Localhost as your preferred network and click on the “import account” button as can be seen in the image below.
Congratulations, you have been able to import a new account using its private key, now compare how through the private key account 5 address is the same as the one in the image below.
You can import accounts into your Metamask wallet in this manner. Doing this procedure now will allow you to import more Ganache server accounts.
After completing this one-time procedure, every time you power up a Hardhat blockchain server, your account will be updated with a new balance of 1,000 ETH. All of these Ethers are now available for usage in your Hardhat development procedures.
Don't miss out on the opportunity to become a sought-after smart contract developer! Get your hands on a copy of my book, "Capturing Smart Contract Development", and gain the skills and knowledge you need to excel in this exciting field. And while you're at it, be sure to subscribe to my channel to stay up to date with the latest web3 development videos.
Conclusion
In conclusion, this guide offers two methods, the Hardhat and Ganache methods, to add unlimited free Ethers to a Metamask wallet for testing and development purposes. Both methods require the installation of NodeJs, the Chrome extension for Metamask, and the use of either the Hardhat or Ganache framework. By following the steps outlined in the guide, users can easily load Ethers onto their Metamask wallet and have a plentiful supply available for testing and developing Ethereum smart contracts.
That’s it for this tutorial, thanks for tuning in, and see you at the next tutorial!
About the Author
Gospel Darlington is a full-stack blockchain developer with 7
years of experience in the software development industry.
By combining Software Development, writing, and teaching, he demonstrates how to build decentralized applications on EVM-compatible blockchain networks.
For more information about him, kindly visit and follow his page on Twitter, Github, LinkedIn, or his website.
Top comments (0)