Giter Club home page Giter Club logo

kitty_party's Introduction

Kitty Party

A Kitty Party is an informal savings scheme in which participants pool money each month, and a rotating winner gets that aggregated sum. There are as many iterations as participants, and the primary benefit is to be able to access a lump sum amount. There are variations on how the claimant is decided each cycle.

The primary goal of this project is to model this process, keeping best practices and Consensys final project requirements in mind.


Overview of Design

Installation

Aside from truffle, the only noteworthy item is that to test oraclize, we need the Ethereum Bridge to be installed. More details below in the testing section.

Use of a Library

A very basic library that checks array bounds, linked with ExternalUintArrayStorage.sol.

Use of a Circuit Breaker

  • CircuitBreaker.sol has modifiers
      modifier notInEmergency(){require(circuitBreakerState == CircuitBreakerState.NoEmergency,"no emergency"); _;}
      modifier inEmergency(){require(circuitBreakerState != CircuitBreakerState.NoEmergency, "not in emergency"); _;}
      modifier inRedAlert(){require(circuitBreakerState == CircuitBreakerState.RedAlert, "in red alert"); _;}
  • KittyPartyBase.sol descends from CircuitBreaker, and uses the modifiers

Stretch Goal - Upgradable Contract

The lottery for a kitty party needs some form of randomization, and the goal was to be able to upgrade the randomization part of a deployed contract. This then meant that the storage needed to be separated out, and passed to a new randomizer, whose requirement is to implement IRandomizeRangeToArray.sol. It also meant that there was need for a uniform interface to be able to call the randomization that was currently installed.

/// @dev abstract function implementation, that makes the randomizer fill out the results
function doInitialLottery() internal {
    IRandomizeRangeToArray randomizer = IRandomizeRangeToArray(upgradableRandomizerAddress);
    randomizer.randomize(numberOfParticipants, externalStorageAddress);
}

There are two implementations of IRandomizeRangeToArray.sol:

Stretch Goal - Use of Oraclize

In determining a random order of winners, a Wolfram Alpha query is used through Oraclize. This is wrapped in the contract RandomIndicesOraclizeBase.sol, which will produce a list of n integers within the range of 0 to y.

Stretch Goal - Use of ENS

sequential.kittyparty.test is registered on ropsten, please visit with Metamask in a ropsten account.

This currently points to the deployed KittyPartySequential.sol contract, and is utilized in the frontend code:

//when on ropsten, can use ENS for contract address
var myContractAddress = "";
var myContractAbi = [..];
web3.eth.ens.getAddress('sequential.kittyparty.test').then((address)=>{
  window.myContract = new window.web3.eth.Contract (myContractAbi,address);
  refreshContractInfo();
});

Testing

truffle test

The only noteworthy item is that to test oraclize, we need the Ethereum Bridge to be installed

Testnet Address

Front End

Deployed :

  • https://adeelhasan.github.io/kitty_party/
  • this is connected to a KittyPartySequential contract
  • have a ropsten account with at least 1 gWei
  • click "Contribute to this Cycle"
  • the metamask confirmation should come up
  • state will get updated to reflect that the participant has contriuted for current cycle

Presenatation

https://vimeo.com/340220008 PowerPoint used in the video


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.