genesisdotre / ethereum-auction

Multiple variants of auctions on Ethereum. Deployed to Ropsten.

Home Page:https://ropsten.etherscan.io/address/0x128008e54cd4e56c4d7908628c37949d8dd67933#code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Since Solidity 0.5.0 there are some changes.

You'll need to:

  • npm install
  • npm run test

This is required so that the locally installed Truffle version is used.

1. Simple auction

Auction.sol

Ethereum was designed with financial applications in mind, that is why auction is an equivalent of "Hello World".

There are many existing implementations of an auction, here is one of them: http://solidity.readthedocs.io/en/v0.4.21/solidity-by-example.html#simple-open-auction

The significant difference:

  • bid just before the end increases the time

2. Multiple items

AuctionMultiple.sol

3. Multiple items, with guranteed placements

AuctionMultipleGuaranteed.sol

For example:

  • selling seats at a workshop in an auction and having 5 place guaranteed at certain price.
  • auctioning memberships to an exclusive villa

Scalability issues

For simplicity currenly there is an artificial limit of 2000 accounts participating in the auction.

See test-gasLimit folder for more information about testing gas limits.

Longer term, it is perfectly possible to avoid limitation by providing starting index to each loop. That, however would increase complexity and development time.

We are not selling tickets to Burning Man or The Rolling Stones at Wembley Stadium, 2000 limit is reasonable for now.

premature optimization is the root of all evil

https://en.wikiquote.org/wiki/Donald_Knuth#Computer_Programming_as_an_Art_(1974)

Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.

Front-end Dapp

  • https://genesis.re/casacrypto
  • Currently read-only functionality
  • Constructor parameters: 100000000000000000, "membership in Casa Crypto", 1538351999, "0x09b25F7627A8d509E5FaC01cB7692fdBc26A2663", 5, 2, 1000000000000000000

Tests

  • Aiming for 100% coverage.
  • truffle test gives an error: Error: The contract code couldn't be stored, please check your gas amount.
  • When running tests individually it works OK:
    • truffle test ./test/Auction.js
    • truffle test ./test/AuctionMultiple.js
    • truffle test ./test/AuctionMultipleGuaranteed.js
    • truffle test ./test-gaslimit/GasLimit.js (expect long wait)
  • TODO: better tooling: https://blog.colony.io/code-coverage-for-solidity-eecfa88668c2

Think

  • Can buyerA outbid buyerA? Does it make any sense in terms of game theory incentives? Pay extra 25% to extend the auction? It's not me to judge, there could be a valid reason for that.
  • With single item auction, outbidding towards the end makes sense to increase time. Does it make sense with multiple items?
  • How winners communicate with the owner about shipping address? Currently setting instructions on-chain. Signing message with the private key (complicated) or off-chain communication possible too.
  • So many fields when reading contract on Etherscan (inheritance surely can be simplified)

Security audits

  • Please don't hack.
  • Please don't kill.
  • Be kind - open an issue, submit a pull request.

Acknowledgements

Thanks to @GriffGreen and @fosgate29 for reviewing early versions of the code.

This is my first contract I wrote from start to finish, not using copy-paste method.

I'm grateful for Kleros and their IICO model that motivated me to level up my coding skills. You can view my commits to their smart contract code here.

About

Multiple variants of auctions on Ethereum. Deployed to Ropsten.

https://ropsten.etherscan.io/address/0x128008e54cd4e56c4d7908628c37949d8dd67933#code


Languages

Language:JavaScript 96.9%Language:Solidity 1.6%Language:HTML 1.5%Language:CSS 0.1%