Code Monkey home page Code Monkey logo

auction's Introduction

Simple Auction Smart Contract

The Simple Auction Smart Contract is a Solidity-based smart contract that enables the creation of a simple auction system for Non-Fungible Tokens (NFTs). The contract allows bidders to place bids on a specific NFT, with the highest bidder being declared the winner when the auction ends. The owner of the NFT can set a reserve price, and the auction will not end if the highest bid is below the reserve price.

The Simple Auction Smart Contract is designed to handle multiple simultaneous auctions for different NFTs.

Getting Started

Prerequisites

To use the Simple Auction Smart Contract, you will need:

  • An Ethereum wallet such as MetaMask
  • Access to the Ethereum network, either through a local development environment or a public network such as Rinkeby or Mainnet.

Deployment

To deploy the Simple Auction Smart Contract:

  1. Copy the contents of contracts/simple_auction.sol into a new file in your Solidity development environment.
  2. Compile the contract using a Solidity compiler such as Remix.
  3. Deploy the contract to the Ethereum network using a tool such as Truffle or Hardhat.

Interacting with the Contract

Once deployed, you can interact with the Simple Auction Smart Contract using an Ethereum wallet such as MetaMask.

Creating an Auction

To create a new auction, call the createAuction function with the following parameters:

  • nftAddress: The address of the NFT contract.
  • tokenId: The ID of the NFT being auctioned.
  • reservePrice: The reserve price for the auction.
  • duration: The duration of the auction in seconds.

The function will return the ID of the new auction.

Placing a Bid

To place a bid on an auction, call the placeBid function with the following parameters:

  • auctionId: The ID of the auction.
  • amount: The amount of the bid, in Wei.

If the bid is successful, the function will return true. If the bid is not successful, it will throw an error.

Cancelling an Auction

To cancel an auction, call the cancelAuction function with the following parameter:

  • auctionId: The ID of the auction to cancel.

The function will cancel the auction and return the NFT to the owner.

Ending an Auction

To end an auction, call the endAuction function with the following parameter:

  • auctionId: The ID of the auction to end.

The function will transfer the NFT to the highest bidder and transfer the bid amount to the owner of the NFT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.