DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Deploying Smart Contract on Ethereum Blockchain
  • How To Use Ethereum Events Properly: An Solidity Dapp Tutorial
  • The Power of Zero-Knowledge Proofs: Exploring the New ConsenSys zkEVM
  • How To Deploy an ERC-20 Smart Contract on Avalanche With Infura

Trending

  • Secure Your API With JWT: Kong OpenID Connect
  • Maximizing Developer Efficiency and Productivity in 2024: A Personal Toolkit
  • Exploring the Frontiers of AI: The Emergence of LLM-4 Architectures
  • Modern Python: Patterns, Features, and Strategies for Writing Efficient Code (Part 1)
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Launch Your Ethereum Donation dApp Today: Easy Steps With MetaMask, Alchemy, and GitHub Codespaces

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

This guide offers a straightforward walkthrough on building and launching your first Ethereum dApp, "BuyACoffee," using MetaMask, Alchemy, and GitHub Codespaces.

By 
Rajesh Gheware user avatar
Rajesh Gheware
·
Feb. 21, 24 · Opinion
Like (1)
Save
Tweet
Share
2.0K Views

Join the DZone community and get the full member experience.

Join For Free

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.create a new app

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 your wallet id from MetaMask UI
Get your wallet id from MetaMask UI

Insert your wallet id here and click on Send Me ETH to receive 0.5 test ETH

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: 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. 

web3-buy-me-a-coffee

  • 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 the 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 the MetaMask extension is available. See the following snapshot. You may have a URL that is provided by GitHub Codespaces.

Web App connected to your blockchain dApp

Web App connected to your blockchain dApp

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 to the smart contract deployed

Dashboard to view all the transactions related to the smart contract deployed

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, Buy Me A Coffee.

Blockchain Ethereum GitHub Smart contract

Published at DZone with permission of Rajesh Gheware. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Deploying Smart Contract on Ethereum Blockchain
  • How To Use Ethereum Events Properly: An Solidity Dapp Tutorial
  • The Power of Zero-Knowledge Proofs: Exploring the New ConsenSys zkEVM
  • How To Deploy an ERC-20 Smart Contract on Avalanche With Infura

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: