Skip to content

icekidtech/auction-app

Repository files navigation

Ethereum Auction dApp

A decentralized auction application built with Solidity smart contracts and Next.js. This project demonstrates a complete blockchain application that allows users to create auctions, place bids, and manage the auction lifecycle.

Auction dApp

Features

Smart Contract Functionality

  • Timed auctions with automatic ending
  • Highest bid tracking
  • Automatic refund of outbid participants
  • Secure funds transfer to beneficiary on auction completion

Frontend Interface

  • Connect MetaMask wallet
  • View current auction status
  • Place bids with ETH
  • Withdraw previous bids if outbid
  • End auction when time expires

Technologies Used

Smart Contracts

  • Solidity ^0.8.28
  • Hardhat development environment
  • Hardhat Ignition for deployments
  • TypeScript for type-safe deployment scripts

Frontend

  • Next.js React framework
  • Ethers.js v5.8.0 for blockchain interactions
  • TypeScript for type safety
  • Styled-JSX for component styling

Testing

  • Hardhat testing framework
  • Chai assertion library

Project Structure

Prerequisites

  • Node.js v16+ and npm
  • MetaMask or another Ethereum wallet browser extension
  • Basic knowledge of Ethereum and smart contracts

Installation & Setup

  1. Clone the repository.
  2. Install dependencies.
  3. Compile contracts.
  4. Generate TypeScript contract types.

Usage

Local Development

  1. Start a local Ethereum node.
  2. Deploy the auction contract.
  3. Update the contract address in index.tsx with the deployed contract address.
  4. Start the frontend.
  5. Access the application at http://localhost:3000 with MetaMask installed.

Configuring MetaMask

  1. Open MetaMask and add a new network:
  2. Import one of the private keys shown when you started the Hardhat node to interact with the dApp.

Testing

Run the test suite with:

npx hardhat test

Smart Contract Details

SimpleAuction Contract

The SimpleAuction contract implements a time-limited auction with the following main functions:

  • constructor(uint _biddingTime, address payable _beneficiary) - Creates a new auction.
  • bid() - Submit a bid (payable function).
  • withdraw() - Withdraw funds from previous outbid.
  • auctionEnd() - End the auction and transfer funds to the beneficiary.

Events

  • HighestBidIncreased(address bidder, uint amount) - Emitted when a new highest bid is placed.
  • AuctionEnded(address winner, uint amount) - Emitted when the auction ends.

Troubleshooting

Common Issues

MetaMask Connection Problems

  • Ensure MetaMask is connected to the correct network.
  • Refresh the page.
  • Check console logs for specific errors.

Dependency Conflicts

  • This project uses ethers v5.8.0, which may conflict with other packages requiring ethers v6.
  • Use the --legacy-peer-deps flag if needed when installing new packages.

Contract Deployment Failures

  • Ensure your Hardhat node is running.
  • Clear Ignition cache if needed: rm -rf .ignition.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Hardhat
  • Next.js
  • Ethers.js
  • TypeChain

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project.
  2. Create your feature branch: git checkout -b feature/amazing-feature.
  3. Commit your changes: git commit -m 'Add some amazing feature'.
  4. Push to the branch: git push origin feature/amazing-feature.
  5. Open a Pull Request.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published