-
Notifications
You must be signed in to change notification settings - Fork 0
/
SealBidAuction_final
42 lines (33 loc) · 1.28 KB
/
SealBidAuction_final
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//SPDX-License-Identifier: MIT
// Warning: Do not use for actual funds.
pragma solidity ^0.8.9;
contract SealedBidAuction {
//Auction parameters
address public immutable beneficiary;
uint public biddingEnd;
unit public revealEnd;
// State of the Auction
uint public highestBid;
address public highestBidder;
bool public hasEnded;
//Amount withdrawable of previous bids
mapping(address => uint) pendingReturns;
// Events
event AuctionEnded(address winner, uint amount);
constructor (address _beneficiary, uint _durationBiddingMinutes, uint _durrationRevealMinutes) {
beneficiary = _beneficiary;
biddingEnd = block.timestamp + _durationBiddingMinutes * minutes;
revealEnd = biddingEnd + _durationRevealMinutes * 1 minutes;
}
function withdraw() external returns (uint amount) {
amount = pendingReturns[msg.sender];
if (amount > 0) {
pendingReturns[msg.sender] = 0;
payable(msg.sender).transferable(amount);
}
//optional: return amount;
}
function generateSealeBid(uint _bidAmount, bol _isLegit, string memory _secret) public pure returns (bytes32 sealedBid) {
sealedBid = keccack256(abi.encodePacked(
_bidAmount, _isLegit, _secret));
}