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.
- Timed auctions with automatic ending
- Highest bid tracking
- Automatic refund of outbid participants
- Secure funds transfer to beneficiary on auction completion
- Connect MetaMask wallet
- View current auction status
- Place bids with ETH
- Withdraw previous bids if outbid
- End auction when time expires
- Solidity ^0.8.28
- Hardhat development environment
- Hardhat Ignition for deployments
- TypeScript for type-safe deployment scripts
- Next.js React framework
- Ethers.js v5.8.0 for blockchain interactions
- TypeScript for type safety
- Styled-JSX for component styling
- Hardhat testing framework
- Chai assertion library
- Node.js v16+ and npm
- MetaMask or another Ethereum wallet browser extension
- Basic knowledge of Ethereum and smart contracts
- Clone the repository.
- Install dependencies.
- Compile contracts.
- Generate TypeScript contract types.
- Start a local Ethereum node.
- Deploy the auction contract.
- Update the contract address in
index.tsxwith the deployed contract address. - Start the frontend.
- Access the application at http://localhost:3000 with MetaMask installed.
- Open MetaMask and add a new network:
- Network Name: Hardhat Local
- New RPC URL: http://127.0.0.1:8545
- Chain ID: 31337
- Currency Symbol: ETH
- Import one of the private keys shown when you started the Hardhat node to interact with the dApp.
Run the test suite with:
npx hardhat testThe 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.
HighestBidIncreased(address bidder, uint amount)- Emitted when a new highest bid is placed.AuctionEnded(address winner, uint amount)- Emitted when the auction ends.
- Ensure MetaMask is connected to the correct network.
- Refresh the page.
- Check console logs for specific errors.
- This project uses ethers v5.8.0, which may conflict with other packages requiring ethers v6.
- Use the
--legacy-peer-depsflag if needed when installing new packages.
- Ensure your Hardhat node is running.
- Clear Ignition cache if needed:
rm -rf .ignition.
This project is licensed under the MIT License - see the LICENSE file for details.
- Hardhat
- Next.js
- Ethers.js
- TypeChain
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project.
- Create your feature branch:
git checkout -b feature/amazing-feature. - Commit your changes:
git commit -m 'Add some amazing feature'. - Push to the branch:
git push origin feature/amazing-feature. - Open a Pull Request.