How to Deploy a Smart Contract in 5 Minutes
Blockchain development tutorial 01 — using Hardhat

There are many ways to deploy a smart contract. In this article, I will share the way to deploy a smart contract using hardhat. There is no pre-requisite required.
5 steps to deploy a smart contract
- Set up the environment
- Initiate a hardhat project
- Configuration
- Code for Deployment
- Deploy
Step1. Set up the environment
Step1, run the code in your terminal.
We start by creating a project folder, and use npm init -y
to generate an npm project. -y
means say yes to every prompt.
Then we install the hardhat
library. Hardhat is an Ethereum development environment. It helps to test, compile, deploy and debug smart contracts.
Remember to install all dependencies based on your project. For example, in the case of an NFT smart contract, you might want to add npm install @openzeppelin/contracts
.
Step2. Initiate a hardhat project
Stay in the project folder, and use the command npx hardhat
to create a basic sample hardhat project. Choose the default option for every prompt question. Your terminal will look like this:

Now in your project folder, there are many folders with a sample smart contract under contract folder. Let’s delete the following files:test/sample-test.js
, script/sample-script.js
, contracts/Greeter.sol
.
And then save your smart contract under the\contracts
folder.
Step3. Configure network and private key
Let’s use Mumbai, Polygon’s Testnet as for demonstration. Open hardhat.config.js
and replace the existing code with the following code.
Make sure you choose the correct solidity version, add your private key and Mumbai RPC. You can find a list of RPC in the official document. Since this file contains your private key, you might want to keep it on your local machine.
You can configure other networks in the networks section, and in step5 you can choose which network to use.
Unfamiliar with RPC? I was also confused. This article helped me out. In short, an RPC is like an API address in Web2.0.
Step4. Code for Deployment
Now we set up the environment and configuration file, let’s work on the code that will help deploy the smart contract.
Create a file deploy.js
under \scripts
folder, and copy the following content:
The code is self-explanatory. Essentially we just use hre.ethers
to get our contract and deploy it. Here are some tips:
- In line 2,
your-contract-name
should not contain ‘.sol’. If your contract filename ismyContract.sol
, just usemyContract
here. - In line 3, provide all parameters required by the
constructor
of your smart contract. - From lines 7 to 11, you can try to interact with your smart contract by invoking its functions.
Step5. Deploy
The last step is the easiest, just use the command: npx hardhat run scripts/deploy.js --network mumbai
The expected terminal output will look like this:

Remember your smart contract address, you will use it when building the front end.
Parting Words
There you have it! I hope this tutorial helped you deploy your smart contract. Please feel free to leave a comment if you have any questions or suggestions. If you want me to write other topics about blockchain development, please also let me know!
Want to Connect?Please feel free to reach out (my LinkedIn) if you have any questions, feedback, or even just a random chat.