A simple dollar auction
Implemented in Solidity using Truffle.
Rules:
- Player 1 places his bid
- Player 2 places his bid (has to match the previous bid)
- If no other player places a bid within the next minute, Player 2 receives the full reward
- If Player 1 (or some other player) places a matching bid, the timer is reset
- Players keep bidding until the timer runs out
- Game Theory and the Sunk Cost Fallacy dictates that the timer will never run out and the pool of bids will grow infinitely large until all money has been spent
- The only globally optimal solution for all players is to not play the game unless one can be sure that he will be the only player
Live contract
Ropsten Test Network: https://ropsten.etherscan.io/address/0x60d772Fa8E8B98c50Bb370892B0696f12beD83d5
Installation:
- Clone:
git clone https://github.com/Kaisle/DollarAuctionSolidity && cd DollarAuctionSolidity
npm install
- Set up a local blockchain:
ganache-cli
Running:
- Run
sudo truffle migrate --reset
in root
You might need to configure truffle.js to point to your local blockchain:
development: { host: "localhost", // IP here port: 7545, // Port number here network_id: "*" // Match any network id },
You can now interact with the smart contract on your local blockchain.
Using TruffleContract to make calls in JS:
- Run
node interact.js
in root - Modify the code in
interact.js
to make your own calls using the Web3 and Truffle-Contract API's.
Testing
- Run
truffle test
in root
Default parameters
- Timer interval = 60 seconds
- Minimum bid = 0.01 ETH