Skip to content
/ hardhat-starter Public template

Simplify your Ethereum smart contract deployment with this Hardhat starter template integrated with Alchemy API. Developed by Roqqet Media, this kit empowers you to seamlessly develop, test, and deploy contracts using the reliable infrastructure of Alchemy.

Notifications You must be signed in to change notification settings

roqqetmedia/hardhat-starter

Repository files navigation

Hardhat + Alchemy + TypeScript Starter Template

Made with ❤ by Roqqet Media

🤝 Features

  • hardhat 2
  • alchemy

⌨️ Installation

Install NPM packages

yarn install
# or
npm install

🌐 How to Deploy a Smart Contract to the Sepolia Testnet

Learn how to deploy smart contracts to the Sepolia testnet, the preferred Ethereum blockchain for testing decentralized applications.

🔑 Create Your App and Obtain an API Key

To get started, create your account on Alchemy by clicking on this link: ** https://dashboard.alchemy.com/signup/?a=deploy-to-sepolia

After creating an Alchemy account, you can generate an API key by creating an app. With this key, we can make requests to the Sepolia test network. To create an app, click on the "Create App" button located in your Alchemy Dashboard.

Create App

Name and describe your app, select Ethereum as the chain, and Sepolia as the network. Finally, create the app.

Create App Form

🦊 Setting Up Your Ethereum Account

To send and receive transactions on Ethereum, you'll need an Ethereum account. To get started, you can download Metamask for free and create an account. Once you have an account, you'll need to switch to the Sepolia Network.

Follow the steps below to switch:

Metamask account

Metamask account network

In the blank boxes, enter the details mentioned in the Sepolia Testnet section. Then, click "Save" and you're all set.

Metamask network form

🪙 Adding Ether from a Sepolia Faucet

To deploy our smart contract on the test network, we need some fake Eth. To get Eth, you can visit the Sepolia faucet and enter your Sepolia account address. Then click on "Send Me Eth". It may take a while to receive your fake Eth because of network traffic. You should see the Eth in your Metamask account soon after.

copy Metamast account

⚙️ Integrate Metamask and Alchemy with Your Project

To send any transaction from your virtual wallet, you need to sign it with your unique private key. But how can you securely provide your program with this permission? The solution is simple: you can safely store your private key (as well as your Alchemy API key) in an environment file.

To get private key from your metamask wallet,

To get HTTP URL from your alchemy account, see the below steps.

For your private key, follow these instructions. And for the HTTPS URL, just check out the steps below.

alchemy app

alchemy view key

alchemy api

Your .env file should look like this:

ALCHEMY_TESTNET_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/your-api-key
TESTNET_PRIVATE_KEY=your-private-key
  • you can copy .env.example file as well.

🚀 Deploying Contract

Let's deploy our smart contract. Open your command line and enter the following command:

npx hardhat run deployments/deploy.js --network sepolia

After executing the previous command, you should see something like this:

Contract Deployed to Address: 0xD80C8976a4EB599b11c831a5470f95CfBD0E99D5

Go to the Sepolia etherscan and search for our contract with the printed address.

Sepolia etherscan

We should able to see that it has been deployed successfully.

Sepolia etherscan creation

Ensure that the From address matches your Metamask account address. The To address should display "Contract Creation", but upon clicking the transaction, we will see our contract address in the To field.

You can check the deployment status in the Alchemy Dashboard.

Go to your app, scroll to the bottom, and you will see something like this.

alchemy dashboard api

🔰 Deploy on local network

npx hardhat run scripts/deploy.ts

After executing the previous command, you should see something like this:

Contract Deployed to Address: 0x5FbDB2315678afecb367f032d93F642f64180aa3

🧪 Testing contracts

npx hardhat test

About

Simplify your Ethereum smart contract deployment with this Hardhat starter template integrated with Alchemy API. Developed by Roqqet Media, this kit empowers you to seamlessly develop, test, and deploy contracts using the reliable infrastructure of Alchemy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published