Code Monkey home page Code Monkey logo

open-auction's Introduction

Open-Auction

A smart contract is developed to support the process of Open auction. An open auction is a kind of auction in which the bid raised is transparent to other participants in the contest. The ethereum smart contract developed will support the auction in raising a bid, withdrawing money from the bid and an option to end the auction. The smart contract is built using the Truffle console and Ganache which are part of Truffle framework. Ganache is the personal block chain that allows developers to create smart contracts.

Brief Explanation of Methods

function bid() public payable

  1. This payable method which is used to collect ethers is used to raise the bid in the open auction.
  2. In order to raise a proper bid two conditions are essentially required to be met.
  3. One is the auction should be still alive. Second requirement is that the newly bid value should be greater than the already existing highest bid value. This is written as part of the require(condition) part.
  4. Once a proper bid is raised, then the existing highest bidder will be sent to pendingReturns[] mapped with highestBidder and highestBid raised by him.
  5. The newly bid user will now become the highest bidder and the newly bid value becomes the highestBid value.

function withdraw() public returns (bool)

  1. This method is used to withdraw/send back that are in the pendingReturns array.
  2. To avoid the re-entrancy attack the pendingReturns of the sender is made equal to 0 when there is some amount greater than 0 associated in returns. Otherwise, the attacker may keep on attacking until he drains the amount.
  3. The function returns true, if the withdrawal is successful. Otherwise it returns false.

function auctionEnd() public

  1. This method is invoked to end the auction and can be triggered only by the beneficiary.
  2. To make sure that the beneficiary has only triggered the auctionEnd method we have a require condition written at the beginning.
  3. Once the auctionEnd() method is invoked it cannot be called again. This is checked by the flag auctionAlive which is set to false, when once invoked.

open-auction's People

Contributors

nikhil6m avatar

Stargazers

 avatar

Watchers

James Cloos avatar

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.