Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donguillotine/decentralized-auction-contract
A decentralized auction platform that allows users to create time-bound auctions, place bids, and automatically manages the auction lifecycle including bid placement, auction closing, and fund distribution.
https://github.com/donguillotine/decentralized-auction-contract
auction blockchain chai decentralized-application ethereum ethersjs hardhat lisk openzeppelin smart-contracts solidity
Last synced: 11 days ago
JSON representation
A decentralized auction platform that allows users to create time-bound auctions, place bids, and automatically manages the auction lifecycle including bid placement, auction closing, and fund distribution.
- Host: GitHub
- URL: https://github.com/donguillotine/decentralized-auction-contract
- Owner: DonGuillotine
- Created: 2024-10-04T13:28:55.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-10-16T10:12:43.000Z (4 months ago)
- Last Synced: 2024-11-21T07:15:51.814Z (2 months ago)
- Topics: auction, blockchain, chai, decentralized-application, ethereum, ethersjs, hardhat, lisk, openzeppelin, smart-contracts, solidity
- Language: Solidity
- Homepage: https://sepolia-blockscout.lisk.com/address/0x635C0C9231efE6b2e85aFc6Cd7F26aEDC3b99044?tab=write_contract
- Size: 109 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AuctionSystem Smart Contract
AuctionSystem is a decentralized auction platform built on Ethereum. It allows users to create time-bound auctions, place bids, and automatically manages the auction lifecycle including bid placement, auction closing, and fund distribution.
## Features
- Create time-bound auctions with specified start and end times
- Place bids on active auctions
- Automatic handling of highest bid updates
- Secure withdrawal mechanism for non-winning bidders
- Automatic transfer of winning bid to the seller upon auction completion
- Comprehensive event logging for frontend integration
- Gas-optimized operations using modern Solidity patterns## Technology Stack
- Solidity 0.8.24
- Hardhat Development Environment
- OpenZeppelin Contracts 5.0.0
- Ethers.js 6.x
- Chai for testing## Prerequisites
- Node.js v14.x or later
- npm 6.x or later
- An Ethereum wallet with Sepolia testnet ETH for deployment## Installation
1. Clone the repository:
```
git clone https://github.com/DonGuillotine/decentralized-auction-contract.git
cd decentralized-auction-contract
```2. Install dependencies:
```
npm install
```3. Create a `.env` file in the root directory with the following content:
```
LISK_SEPOLIA_RPC_URL=your_rpc.sepolia-api_key
PRIVATE_KEY=your_ethereum_private_key
ETHERSCAN_API_KEY=your_etherscan_api_key
```## Usage
### Compile Contracts
```
npx hardhat compile
```### Run Tests
```
npx hardhat test
```
#### All Tests Passed![alt text](image.png)
### Deploy to Sepolia Testnet
```
npx hardhat run scripts/deploy.js --network lisk-sepolia
```This script will deploy the contract and automatically verify it on Etherscan.
## Contract Interface
### Functions
1. `createAuction(uint256 _startTime, uint256 _endTime)`: Create a new auction
2. `placeBid(uint256 _auctionId)`: Place a bid on an active auction
3. `endAuction(uint256 _auctionId)`: End an auction after its end time
4. `withdrawBid(uint256 _auctionId)`: Withdraw a non-winning bid
5. `getAuctionDetails(uint256 _auctionId)`: Get details of a specific auction### Events
1. `AuctionCreated(uint256 indexed auctionId, address indexed seller, uint256 startTime, uint256 endTime)`
2. `BidPlaced(uint256 indexed auctionId, address indexed bidder, uint256 amount)`
3. `AuctionEnded(uint256 indexed auctionId, address winner, uint256 amount)`
4. `WithdrawalMade(uint256 indexed auctionId, address indexed bidder, uint256 amount)`## Security Considerations
- The contract uses OpenZeppelin's `ReentrancyGuard` to prevent reentrancy attacks
- Time-based operations use `block.timestamp`, which can be slightly manipulated by miners (maximum of a few seconds)
- The contract has been thoroughly tested, but we recommend a professional audit before mainnet deployment## Gas Optimization
- Utilizes mappings for efficient data storage and retrieval
- Implements checks-effects-interactions pattern to prevent reentrancy
- Uses custom errors for gas-efficient error handling## Testing
The contract includes a comprehensive test suite covering various scenarios including:
- Auction creation
- Bidding mechanics
- Auction ending
- Bid withdrawals
- Edge cases and error conditionsRun the tests using the command mentioned in the Usage section.
## Deployment
The deployment script (`scripts/deploy.js`) handles:
1. Contract deployment to the Sepolia testnet
2. Waiting for block confirmations
3. Automatic contract verification on Etherscan## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
## Contact
For any queries or support, please open an issue in the GitHub repository.