Skip to content

Commit 51f941b

Browse files
Merge pull request #6 from Jagpreet153/nft_Jagpreet153
feat: nft issue resolved
2 parents 8c8bbe7 + 6a49a7c commit 51f941b

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

contracts/smartbid.sol

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
contract EnglishAuction {
4+
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
5+
import "@openzeppelin/contracts/access/Ownable.sol";
6+
7+
contract EnglishAuction is ERC721, Ownable {
58
address payable public auctioneer;
69
uint256 public stblock; // start time
710
uint256 public etblock; // end time
@@ -12,6 +15,7 @@ contract EnglishAuction {
1215
Ended,
1316
Cancelled
1417
}
18+
1519
Auc_state public auctionState;
1620

1721
uint256 public highestBid;
@@ -24,34 +28,29 @@ contract EnglishAuction {
2428

2529
event bidPlaced (address bidder, uint bidAmount);
2630

27-
constructor() {
31+
constructor(address initialOwner) ERC721("EnglishAuction", "EA") Ownable(initialOwner) {
2832
auctioneer = payable(msg.sender);
2933
auctionState = Auc_state.Running;
3034
stblock = block.number;
3135
etblock = stblock + 240;
3236
bidInc = 1 ether;
3337
}
3438

35-
36-
3739
modifier NotOwner() {
3840
require(auctioneer != msg.sender);
3941
_;
4042
}
41-
modifier Owner() {
42-
require(auctioneer == msg.sender);
43-
_;
44-
}
43+
4544
modifier Start() {
4645
require(block.number > stblock, "Not yet Started");
4746
_;
4847
}
4948

50-
function cancelAuc() public Owner{
49+
function cancelAuc() public onlyOwner {
5150
auctionState=Auc_state.Cancelled;
5251
}
5352

54-
function endAuc() public Owner{
53+
function endAuc() public onlyOwner {
5554
auctionState=Auc_state.Ended;
5655
}
5756

@@ -79,7 +78,6 @@ contract EnglishAuction {
7978
}
8079

8180
emit bidPlaced(msg.sender, currentBid);
82-
8381
}
8482

8583
function finalizeAuc() public {
@@ -103,9 +101,7 @@ contract EnglishAuction {
103101
person.transfer(value);
104102
}
105103

106-
107-
108-
function withdraw()public{
104+
function withdraw() public {
109105
require(auctionState==Auc_state.Cancelled || auctionState==Auc_state.Ended || block.number>etblock, "Auction still running");
110106
require(bids[msg.sender]>0, "Only bidders can withdraw");
111107

@@ -122,7 +118,14 @@ contract EnglishAuction {
122118
}
123119
bids[msg.sender]=0;
124120
person.transfer(value);
125-
}
121+
}
126122

123+
function mint(address to, uint256 tokenId) public onlyOwner {
124+
_mint(to, tokenId);
127125
}
128126

127+
function transferNFT(address from, address to, uint256 tokenId) public onlyOwner {
128+
require(ownerOf(tokenId) == from, "You don't own this token");
129+
safeTransferFrom(from, to, tokenId);
130+
}
131+
}

0 commit comments

Comments
 (0)