Auction functionality

Hi, I want to do add an auction functionality to an nft marketplace. Could someone please help me with the latest links and videos? I already have one auction contract although I dont know if it is the best:

pragma solidity ^0.8.0;

import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "../node_modules/@openzeppelin/contracts/utils/Counters.sol";

contract MorarableToken is ERC721 {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor () ERC721("MorarableToken", "MORA"){}

    struct Item {
        uint256 id;
        address creator;
        string uri;

    mapping (uint256 => Item) public Items;

    function createItem(string memory uri) public returns (uint256){
        uint256 newItemId = _tokenIds.current();
        _safeMint(msg.sender, newItemId);

        Items[newItemId] = Item(newItemId, msg.sender, uri);

        return newItemId;

    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

       return Items[tokenId].uri;
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Migrations {
  address public owner = msg.sender;
  uint public last_completedmigration;

  modifier restricted() {
      msg.sender == owner,
      "This function is restricted to the contract's owner"

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;

Besides I would like help in order to show a front in an html website of this contract.

1 Like

that smart contract looks like only a smart contract for an ERC721 token, also with some code taken from Truffle’s default Migrations smart contract.
You can look at
to get an idea how a marketplace can be made.

Sorry I pasted the wrong one

pragma solidity ^0.8.0;

contract BlindAuction{

    struct Bid {
        bytes32 blindedBid;
        uint deposit;
    address payable public beneficiary;
    uint public biddingEnd;
    uint public revealEnd;
    bool public ended;

    mapping(address => Bid[]) public bids; 

    address public highestBidder;
    uint public highestBid;

    mapping(address => uint) pendingReturns;

    event AuctionEnded(address winner, uint highestBid);

    modifier onlyBefore(uint _time) {require(block.timestamp < _time);_;}
    modifier onlyAfter(uint _time) {require(block.timestamp > _time);_;}     

        uint _biddingTime,
        uint _revealTime,
        address payable _beneficiary
    ) {
        beneficiary = _beneficiary;
        biddingEnd = block.timestamp + _biddingTime;
        revealEnd = biddingEnd + _revealTime;

    function generateBlindedBidBytes32(uint value, bool fake) public view returns (bytes32) {
        return keccak256(abi.encodePacked(value, fake));

    function bid(bytes32 _blindedBid) public payable onlyBefore(biddingEnd) {
            blindedBid: _blindedBid,
            deposit: msg.value

    function reveal (
        uint[] memory _values,
        bool[] memory _fake
        uint length = bids[msg.sender].length;
        require(_values.length == length);
        require(_fake.length == length);

        for (uint i=0; i<length; i++) {
            Bid storage bidToCheck = bids[msg.sender][i];
            (uint value, bool fake) = (_values[i], _fake[i]);
            if (bidToCheck.blindedBid != keccak256(abi.encodePacked(value, fake))) {
        if(!fake && bidToCheck.deposit >= value) {
            if (!placeBid(msg.sender, value)) {
                payable(msg.sender).transfer(bidToCheck.deposit * (1 ether));
        bidToCheck.blindedBid = bytes32(0);

    function auctionEnd() public payable onlyAfter(revealEnd) {
        emit AuctionEnded(highestBidder, highestBid);
        ended = true;
        beneficiary.transfer(highestBid * (1 ether)); 
    function withdraw() public {
        uint amount =   pendingReturns[msg.sender];
        if (amount > 0 ) {
            pendingReturns[msg.sender] = 0;

            payable(msg.sender).transfer(amount * (1 ether));
    function placeBid(address bidder, uint value) internal returns (bool success) {
        if (value <= highestBid) {
            return false;
        if (highestBidder != address(0)) {
            pendingReturns[highestBidder] += highestBid;
        highestBid = value;
        highestBidder = bidder;
        return true;


I ve already done that tutorial

Hi @Mateo03 can you provide the implementation of this code with the frontend?

Have You Found the answer??