Search
Close this search box.

MTVLab: Pioneering DevOps Cloud Training

Launch Your Ethereum Donation dApp Today: Easy Steps with MetaMask, Alchemy, and GitHub Codespaces

By Rajesh Gheware

In the rapidly evolving world of blockchain technology, building decentralized applications (dApps) presents a unique opportunity for developers to explore the potential of Ethereum and smart contracts. This article aims to guide you through the process of creating a simple yet functional dApp, “BuyACoffee,” designed to receive acknowledgments from the readers of Brainupgrade. We’ll use the Ethereum test network Sepolia and platforms like Alchemy and MetaMask for wallet management.

Step 1: Setting Up MetaMask

MetaMask is a popular Ethereum wallet and a gateway to blockchain apps. Here’s how to create a new wallet for our project:

  1. Download and Install MetaMask: Go to the MetaMask website and add the extension to your browser.
  2. Create a New Wallet: Follow the on-screen instructions to create a new wallet. Remember to safely store your recovery phrase.
  3. Connect to Sepolia Test Network: By default, MetaMask uses the Ethereum Mainnet. Switch to the Sepolia test network from the network dropdown.

Step 2: Setting Up Alchemy

Alchemy provides powerful tools for blockchain developers. We’ll use it to deploy our dApp.

  1. Create an Alchemy Account: Sign up at Alchemy and log in.
  2. Create a New App: Navigate to the dashboard and create a new app. Choose “Sepolia” as the network.

Step 3: Funding Your Wallet with Test ETH

Before deploying our dApp, we need some test ETH. Use a Sepolia faucet (search online for “Sepolia faucet“) to receive 0.5 ETH in your MetaMask wallet for testing purposes. Use your MetaMask wallet id.

Get you wallet id from MetaMask UI
Insert your wallet id here and click on Send Me ETH to receive 0.5 test ETH

Step 4: Preparing Your dApp

We’ll use the provided source code for the “BuyACoffee” dApp and web app. You can find the complete code at GitHub – Brainupgrade.

  • Fork the Source Code repo:And use Github Codespaces to launch the browser based IDE to make code changes. See the following snapshot. Click on Create codespace on main and VSCode will be launched in the browser
  • Install Dependencies: Navigate to the dApp directory (BuyMeACoffee-contracts) and run npm install to install the required dependencies.

Step 5: Deploying Your Smart Contract with Alchemy

Using Hardhat, we’ll deploy the smart contract to the Sepolia network.

  1. Configure Hardhat: In the hardhat.config.js, set up the Sepolia network configuration using your Alchemy URL and the private key of your MetaMask account. Set the environment variables SEPOLIA_URL and PRIVATE_KEY (these two are found in the Alchemy app settings)
  2. Deploy the Contract: Run npx hardhat run scripts/deploy.js –network sepolia to deploy your contract to the Sepolia network.

Step 6: Integrating with Your Web App

The web app (located in the “app” folder) interacts with your deployed smart contract.

  1. Configure Your Web App: Update the ./src/App.jsx in the web app folder with the contract address and ./src/utils/BuyMeACoffee.json with the json built when smart contract was deployed.
  2. Run the Web App: Use a local server or a development tool to serve the web app.npm run buildnpm run previewElse, you can dockerize the app and run it using the following commands:docker build -t buy-me-a-coffee-app .docker run -d -p 80:80 buy-me-a-coffee-appOnce app is running, you can open the URL in the browser in which MetaMask extension is available. See the following snapshot. You may have URL that is provided by Github Codespaces.
Buy Me A Coffee
Buy Me A Coffee
Web App connected to your blockchain dApp
  1.  

Step 7: Testing Your dApp

Use MetaMask to interact with your dApp. Ensure you’re connected to the Sepolia network and have some test ETH.

  1. Interact with Your dApp: Use the web app interface and connect to your MetaMask wallet to send a “coffee” (a small ETH transaction) as a token of appreciation.
  2. Monitor Transactions: Use Alchemy’s dashboard to monitor incoming transactions and contract interactions.
Dashboard to view all the transactions related the smart contract deployed
  1.  

Deploying and Testing with GitHub Codespaces

For deployment and testing, GitHub Codespaces offers a convenient cloud-based development environment. Simply fork the provided GitHub repository and open it in Codespaces to start developing and testing your dApp without needing to set up a local development environment.

Conclusion

This walkthrough demonstrates the simplicity and power of creating and deploying a blockchain dApp using MetaMask, Alchemy, and the Sepolia test network. By following these steps, developers can gain hands-on experience with Ethereum smart contracts and the broader ecosystem. Remember, this is just the beginning of your blockchain development journey. The possibilities are endless, and as you grow more comfortable with these tools, you’ll be well on your way to building more complex and impactful decentralized applications.

Happy coding, and may your coffee cup always be full, courtesy of our supportive readers!

If you like the article, please Buy Me A Coffee 

<iframe src=https://buymeacoffee.unigps.in/” title=”BuyMeACoffee”></iframe>

Share:

More Posts

Send Us A Message