So day one is here and it's time to start preparing to be a blockchain developer. This means starting with creating a local Ethereum network. The reason we do this is because it allows us to deploy our solidity contracts, run tests, and debug our code. A local Ethereum network is designed for development, which is exactly what we need.
To set up this network we're going to use an environment called 'Hardhat', which is an environment that developers use to to test, compile, deploy, and debug contracts and dApps (Decentralized Applications) on the Ethereum blockchain. Another bonus to using Hardhat, is that it will provide us with fake test ETH and fake test accounts to work with. This is extremely beneficial, as we know that everything on real blockchain networks is immutable and costly which just doesn't work for testing and debugging.
Disclosure: I am operating on Windows 11
When setting up your local Ethereum network, all you need is a basic understanding of terminal commands. To get started you'll need to install the current LTS version of Node.js which you can find with a quick google search. Next I moved over to my cmd terminal and entered the following commands:
Now, the next step is to run Hardhat with the command npx hardhat, which I did...and had an unfortunate sequence of errors. So I discovered I was getting these errors because I had created the directory within my removable (E:) drive. So I figured the quickest way around this problem was to just restart and create a directory within my main (C:) drive. When I attempted to run Hardhat the second time, it ran perfectly.
To create my new project I selected the first option shown which is 'Create a basic sample project' and ran the following command to complete the setup:
Once I had the running project, I ran a few commands to ensure it was running properly. The commands I ran were: npx hardhat accounts (This displays a list of test Ethereum addresses that hardhat has simulated for us), npx hardhat compile (This compiles the solidity code within the project), and npx hardhat test (This runs the 'test' file within the Hardhat sample folders).
Comments (0)